
//获取登录状态
function checkuserstate() {

    $.getJSON('http://ahbys.ncss.org.cn/getlogstate?callback=?',
			function (data) {
			    if (data.islogin == '1') {
			        $('#login-userState').attr('style', 'display:block;');
			        $('#login-main').attr('style', 'display:none;');
			        $('#login-userState').html('当前用户：<a href="http://ahbys.ncss.org.cn/home" title="点击进入学生管理首页"><span>'
					+ data.fullname + '</span></a>&nbsp;&nbsp;毕业院校：<span>'
					+ data.orgname + '&nbsp;&nbsp;<a id="logout" href="http://ahbys.ncss.org.cn/logout?rul='
					+ document.location.href
					+ '">[退出]</a>'
					);
			    } else {
			        $.getJSON('http://ahbys.ncss.org.cn/rec/getlogstate?callback=?',
							function (data) {
							    if (data.islogin == '1') {
							        email = data.email;
							        $('#login-userState').attr('style', 'display:block;');
							        $('#login-main').attr('style', 'display:none;');
							        $('#login-userState').html('当前用户：<a href="http://ahbys.ncss.org.cn/rec/home" title="点击进入单位管理首页"><span>'
									+ data.fullname + '</span></a>&nbsp;&nbsp;单位名称：<span>'
									+ data.orgname + '&nbsp;&nbsp;<a id="logout" href="http://ahbys.ncss.org.cn/rec/logout?rul='
									+ document.location.href
									+ '">[退出]</a>'
									);

							    } else {
							        $('#login-main').attr('style', 'display:block;');
							        $('#login-userState').attr('style', 'display:none;');
							    }
							});
			    }

			});

}

//解析数据集合，有置顶，无分页，每单位只有一条职位
function onloadlst(viewdivID1, viewdivID2, psize, category, jobType, natureCode) {
    // var params = getParams(psize, category, jobType, natureCode);
    var params = {
        recName: "",
        natureCode: natureCode,
        industryCode: "",
        recScale: "",
        jobTitle: "",
        category: category,
        jobType: jobType,
        areaCode: "",
        degreeCode: "",
        dayLimit: "-1",
        siteId: "", //默认空为全部，00为中心，10001为北京大学
        psize: parseInt(psize), //每页条数
        //pindex: parseInt(pindex),//显示第？页
        callback: "test"
    };
    $.getJSON('http://ahbys.ncss.org.cn/json/general_searchp?callback=?', params,
				function (data) {
				    var lists1 = '';
				    var lists2 = '';
				    var lists = '';
				    var divElement1 = "#" + viewdivID1;
				    var divElement2 = "#";
				    if (viewdivID2 != "") divElement2 = "#" + viewdivID2;
				    var date;
				    var areaCode;
				    var area = "";
				    var topFlag = "";
				    var flag = 1;
				    var index = 0;


				    $.each(data.lst, function () {
				        date = this.postDate.substring(5, 10);
				        areaCode = this.areaCode.substring(0, 2);
				        $.each(provinceItems, function () {
			            if (this.id == areaCode) { area = this.name; }
				        });
				        if (index < 10) {
				            lists = '<tr><td class="jobtop" ><font class="jobareatop">['
								+ area
								+ ']</font>&nbsp;<a href="http://ahbys.ncss.org.cn/job/view_job?jobId='
								+ this.jobId
								+ '" target="_blank">'
								+ this.recName
								+ '</a>('
								+ date
								+ ')</td></tr>';
				        }
				        else {
				            lists = '<tr><td>['
								+ area
								+ ']</font>&nbsp;<a href="http://ahbys.ncss.org.cn/job/view_job?jobId='
								+ this.jobId
								+ '" target="_blank">'
								+ this.recName
								+ '</a>('
								+ date
								+ ')</td></tr>';
				        }

				        index++;
				        if (flag == 1) {
				            lists1 += lists;
				            flag = 2;
				        }
				        else if (flag == 2) {
				            lists2 += lists;
				            flag = 1;
				        }

				    });



				    if (lists1 != '') {
				        $(divElement1).html(lists1);
				    } else {
				        $(divElement1).html("页面加载中...");
				    }

				    if (lists2 != '') {
				        $(divElement2).html(lists2);
				    } else {
				        $(divElement2).html("页面加载中...");
				    }

				}
		);
}

function gb2312Decode(data) {
    string = "";
    str = "";
    d = data;
    n = "";
    c = "";
    execScript("l = LenB(d)", "vbscript");
    execScript("d = MidB(d, 1)", "vbscript");
    for (i = 1; i <= l; i++) {
        execScript("c = AscB(MidB(d, i, 1))", "vbscript");
        if (c < 0x80) {
            execScript("str = Chr(c)", "vbscript");
            string += str;
        }
        else {
            execScript("n = AscB(MidB(d, i + 1, 1))", "vbscript");
            execScript("str = Chr(CLng(c) * &H100 + CInt(n))", "vbscript");
            string += str;
            i = i + 1;
        }
    }
    return string;
}


//解析数据集合，有置顶，无分页，每单位只有一条职位
function onloadunlst(board, viewdivID, psize, category, jobType, natureCode) {
    //var params = getParams(psize, category, jobType, natureCode);
    var params = {
        recName: "",
        natureCode: natureCode,
        industryCode: "",
        recScale: "",
        jobTitle: "",
        category: category,
        jobType: jobType,
        areaCode: "",
        degreeCode: "",
        dayLimit: "-1",
        siteId: "", //默认空为全部，00为中心，10001为北京大学
        psize: parseInt(psize), //每页条数
        //pindex: parseInt(pindex),//显示第？页
        callback: "test"
    };
    $.getJSON('http://ahbys.ncss.org.cn/json/general_searchp?callback=?', params,
				function (data) {
				    var lists = '';
				    var divElement = "#" + viewdivID;
				    var date;
				    var areaCode;
				    var area = "";
				    var topFlag = "";

				    if (board == "index") {//首页
				        $.each(data.lst, function () {
				            date = this.postDate.substring(5, 10);
				            areaCode = this.areaCode.substring(0, 2);
				            $.each(provinceItems, function () {
				                if (this.id == areaCode) { area = this.name; }
				            });
				            if (this.priority == 1) {
				                lists += '<tr><td class="hui21">['
								+ area
								+ ']&nbsp;<a class="hui21" href="http://ahbys.ncss.org.cn/job/view_job?jobId='
								+ this.jobId
								+ '" target="_blank" title="职位名称：'
								+ this.jobTitle
								+ '&#10单位行业：' + this.industry + '&#10单位性质：' + this.nature
								+ '">'
								+ this.recName
								+ '</a>('
								+ date
								+ ')</td></tr>';
				            } else {
				                lists += '<tr><td class="hui21">['
								+ area
								+ ']&nbsp;<a class="hui21" href="http://ahbys.ncss.org.cn/job/view_job?jobId='
								+ this.jobId
								+ '" target="_blank" title="职位名称：'
								+ this.jobTitle
								+ '&#10单位行业：' + this.industry + '&#10单位性质：' + this.nature
								+ '">'
								+ this.recName
								+ '</a>('
								+ date
								+ ')</td></tr>';
				            }


				        });

				    }
				

				    if (lists != '') {

				        $(divElement).html(lists);
				    } else {
				        $(divElement).html("页面加载中...");
				    }
				}

		);
}


