﻿var use_this_page_type = 1;

function usertype_go_page(pagetype) {
    use_this_page_type = pagetype;
    if ($.cookie('__UserType') == null) {
        $(document).ready(function() {
            usertype_show_select();
        });
        return;
    }
    else if (pagetype == 1 && $.cookie('__UserType') == 'userstudent' && $.cookie('__FirstLoad') == null) {
        $.cookie('__FirstLoad', 'value');
        window.location.href = "http://bys.tianjihr.com";
        return;
    }
    else if (pagetype == 2 && $.cookie('__UserType') == 'usersocial' && $.cookie('__FirstLoad') == null) {
        $.cookie('__FirstLoad', 'value');
        window.location.href = "http://www.tianjihr.com/defaultajaxtest.aspx";
        return;
    }

    $.cookie('__FirstLoad', 'value', { domain: 'tianjihr.com', path: '/'});
}

function usertype_show_select() {
    $("#usertype_selShenfen").show();
}

function usertype_change_select(usertype) {
    if (usertype == 1) {
        $("#usertype_sfBtn img").attr("src", "/images/basic/shr.gif");
        $.cookie('__UserType', 'usersocial', { expires: 300, path: '/', domain: 'tianjihr.com'});
        $.cookie('__FirstLoad', 'value', { domain: 'tianjihr.com', path: '/'});
        if (use_this_page_type != 1)
            window.location.href = "http://www.tianjihr.com/defaultajaxtest.aspx";
    }
    else if (usertype == 2) {
        $("#usertype_sfBtn img").attr("src", "/images/basic/bys.gif");
        $.cookie('__UserType', 'userstudent', { expires: 300, path: '/', domain: 'tianjihr.com'});
        $.cookie('__FirstLoad', 'value', { domain: 'tianjihr.com', path: '/'});
        if (use_this_page_type != 2)
            window.location.href = "http://bys.tianjihr.com";
    }
    $("#usertype_selShenfen").hide();
}

usertype_go_page(1);

$(document).ready(function() {
    if ($.cookie('__UserType') == 'userstudent') {
        $("#usertype_sfBtn img").attr("src", "/images/basic/bys.gif");
    }
    else {
        $("#usertype_sfBtn img").attr("src", "/images/basic/shr.gif");
    }
    $("#usertype_sfBtn").click(function() { $("#usertype_selShenfen").toggle(); return false; });
    $("#usertype_shutShenfen").click(function() { $("#usertype_selShenfen").hide(); return false; });
    $("#usertype_selShr").click(function() { usertype_change_select(1); return false; });
    $("#usertype_selBys").click(function() { usertype_change_select(2); return false; });
});
