//获取年龄
function showAge(stime){
    var time = parseInt(stime);
    if(isNaN(time) || time < 1000){
		document.write("-");
		return;
    }

	var now = new Date();
	var oldy = parseInt(time / 10000);
	var oldm =  (parseInt(time /100) - oldy *100);
	var age = now.getYear() - oldy;

	if((now.getMonth() + 1) < oldm){
		age = age - 1;
	}

	if(age <= 0){
		document.write("-");
	}else{
		document.write(age);
	}
}

function showWorkYear(stime){
    var time = parseInt(stime);
	if(time == undefined || time == ''){
		document.write("未指定");
		return;
	}
	var now = new Date();

	var oldy = parseInt(time / 10000);
	var oldm =  (parseInt(time /100) - oldy *100);
	var age = now.getYear() - oldy;

	if((now.getMonth() + 1) < oldm){
		age = age - 1;
	}

	if(age <= 0){
		document.write("不足一年");
	}else{
		document.write(age+"年");
	}
}

function arrIdxValue(arr, idx) {
    var index = parseInt(idx);
    if(isNaN(index)){
        return '-';
    }
    if(arr[index]){
        return arr[index];
    }else{
        return '-';
    }
}

function getFragment(array, number, val){
	var fragment = document.createDocumentFragment();
	if(array.length == 0){
		var _op = document.createElement('option');
		_op.value = 0;
		_op.innerHTML = '无选项';
		fragment.appendChild(_op);
	}else{
		for(var i = 0; i < array.length; i++){
			if(array[i] == undefined){continue;}

			var _op = document.createElement('option');
			if( number == true){
				_op.value = i;
			}else{
				_op.value = array[i].toHTML();
			}
            if(val == _op.value){
                _op.selected = true;
            }
			_op.innerHTML = array[i].toHTML();
			fragment.appendChild(_op);
		}
	}
	return fragment;
}

function countArr(array){
    var c = 0;
    for (var i = 0; i < array.length; i++ ) {
        if(array[i] == undefined){continue;}
        c++;
    }
    return c;
}
function crtOptions(id, array, number, val){
	var obj = document.getElementById(id);
	if(array.length == 0){
		obj.length = 1;
		obj.options[0].text = '无选项';
		obj.options[0].value = 0;
	}
    var j = obj.length ;
	obj.length = j+countArr(array);
	for (var i = 0; i < array.length; i++ ) {
		if(array[i] == undefined){continue;}
		obj.options[j].text = array[i];
		if(number == true){
			obj.options[j].value = i;
		}else{
			obj.options[j].value = array[i];
		}
        if(val == obj.options[j].value){
            obj.options[j].selected = true;
        }
        j++;
	}
}

/*一维数组的操作*/
function showOptions(array, selid){
    if(typeof(array) != 'undefined'){
	crtOptions(selid, array, true, null);
    }
	//var obj = document.getElementById(selid);
	//obj.appendChild(getFragment(array, true));
}

function showOptions2(array, selid, val){
    if(typeof(array) != 'undefined'){
    crtOptions(selid, array, true, val);
    }
	//var obj = document.getElementById(selid);
	//obj.appendChild(getFragment(array, true, val));
}

function showKeyValue(array, selid){
	//crtOptions(selid, array, false);
    if(typeof(array) != 'undefined'){
	var obj = document.getElementById(selid);
	obj.appendChild(getFragment(array, false, null));
    }
}

function showType(array, selid){
	var obj = document.getElementById(selid);
    if((typeof(array) != 'undefined') && (array != undefined) ){
        var fragment = document.createDocumentFragment();
        for(var i = 0; i < array.length; i++){
            if(array[i] == undefined){continue;}
            var _op = document.createElement('option');
            _op.value = array[i].id;
            _op.innerHTML = array[i].name.toHTML();
            fragment.appendChild(_op);
        }
        obj.appendChild(fragment);
    }
}
function showType2(array, selid, val){
	var obj = document.getElementById(selid);
    if((typeof(array) != 'undefined') && (array != undefined) ){
        var fragment = document.createDocumentFragment();
        for(var i = 0; i < array.length; i++){
            if(array[i] == undefined){continue;}
            var _op = document.createElement('option');
            _op.value = array[i].id;
            if(val == _op.value){
                _op.selected = true;
            }
            _op.innerHTML = array[i].name.toHTML();
            fragment.appendChild(_op);
        }
        obj.appendChild(fragment);
    }
}

function getType(array, idx){
    if((typeof(array) == 'undefined') || array == undefined || array == null){
        return '-';
    }
	for(var i = 0; i < array.length; i++){
		if(array[i] == undefined){continue;}
		if( array[i].id == idx){
			return  array[i].name.toHTML();
		}
	}
    return '-';
}

function removeAll(objid){
	var element = document.getElementById(objid);
	while (element.firstChild) {
		element.removeChild(element.firstChild);
	}
}
/*二维数组的操作*/
function showFirst(array, blank, selid){
	var obj = document.getElementById(selid);
	if(array.length == 0){
			var _op = document.createElement('option');
			_op.value = 0;
			_op.innerHTML = '无选项';
			obj.appendChild(_op);
	}else{
		var fragment = document.createDocumentFragment();
		if(blank == true){
			var _op = document.createElement('option');
			_op.value = 0;
			_op.innerHTML = '请选择职能';
			fragment.appendChild(_op);
		}
		for(var i = 1; i < array.length; i++){
			if(array[i] == undefined){continue;}
			var _op = document.createElement('option');
			_op.value = i;
			_op.innerHTML = (array[i][0]).toHTML();
			fragment.appendChild(_op);
		}
		obj.appendChild(fragment);
	}
}
function showSecond(array, idx, objid, showall){
	var obj =  document.getElementById(objid);
	removeAll(objid);

	if(showall == true){
		var jump = 0;
	}else{
		var jump = 1;
	}

	if(array.length == 0 || array[idx] == null){
		var _op = document.createElement('option');
		_op.value = 0;
		_op.innerHTML = '无选项';
		obj.appendChild(_op);
	}else{
		var fragment = document.createDocumentFragment();
		for(var i =(1 + jump); i < array[idx].length; i++){
			if(array[idx][i] == undefined){continue;}
			var _op = document.createElement('option');
			_op.value = (i - 1);
			_op.innerHTML = (array[idx][i]).toHTML();
			fragment.appendChild(_op);
		}
		obj.appendChild(fragment);
	}
}

function showFirst2(array, blank, selid, val){
	var obj = document.getElementById(selid);
	if(array.length == 0){
			var _op = document.createElement('option');
			_op.value = 0;
			_op.innerHTML = '无选项';
			obj.appendChild(_op);
	}else{
		var fragment = document.createDocumentFragment();
		if(blank == true){
			var _op = document.createElement('option');
			_op.value = 0;
			_op.innerHTML = '请选择职能';
			fragment.appendChild(_op);
		}
		for(var i = 1; i < array.length; i++){
			if(array[i] == undefined){continue;}
			var _op = document.createElement('option');
			_op.value = i;
            if(val == _op.value){
                _op.selected = true;
            }
			_op.innerHTML = (array[i][0]).toHTML();
			fragment.appendChild(_op);
		}
		obj.appendChild(fragment);
	}
}
function showSecond2(array, idx, objid, showall, val){
	var obj =  document.getElementById(objid);
	removeAll(objid);

	if(showall == true){
		var jump = 0;
	}else{
		var jump = 1;
	}

	if(array.length == 0 || array[idx] == null){
		var _op = document.createElement('option');
		_op.value = 0;
		_op.innerHTML = '无选项';
		obj.appendChild(_op);
	}else{
		var fragment = document.createDocumentFragment();
		for(var i =(1 + jump); i < array[idx].length; i++){
			if(array[idx][i] == undefined){continue;}
			var _op = document.createElement('option');
			_op.value = (i - 1);
            if(val == _op.value){
                _op.selected = true;
            }
			_op.innerHTML = (array[idx][i]).toHTML();
			fragment.appendChild(_op);
		}
		obj.appendChild(fragment);
	}
}

function getContent(array, idxs){
	var str = '';
    if(array == undefined || array == null){
        return str;
    }
	if(idxs != undefined && idxs != '' ){
        arrs = idxs.split(",");
        for(var i = 0; i < arrs.length; i++){
            if(arrs[i] == undefined){continue;}
            var idx1 = parseInt(arrs[i] / 100);
            var idx2 = arrs[i] - idx1 * 100 + 1;
            if(array[idx1][idx2]){
                str += array[idx1][idx2]+'<br/>';
            }else{
                str +='-<br/>';
            }

        }
	}
	return str;
}
/*反选，全选，是否选中*/
function backSelected(formid){
	$('input[type=checkbox]', '#'+formid).each(function(){
		this.checked = !this.checked;
	})
}
function selectAll(formid){
	$('input[type=checkbox]', '#'+formid).attr('checked', true);
}
function clearAll(formid){
	$('input[type=checkbox]', '#'+formid).attr('checked', false);
}
function haveSelected(formid){
	var selected = false;
	$('input[type=checkbox]', '#'+formid).each(function(){
		if(this.checked == true){
			selected = true;
		}
	})
	if(selected == false){
		alert("请先选择要操作的记录");return false;
	}else{
		return true;
	}
}

function numalign(num){
    var str = "000000" + num;
    document.write(str.substr(str.length - 6));
}

function forbidSub(subid){
$('#'+subid).keydown(
	function(e){
		var key = window.event ? e.keyCode : e.which;
		if(key.toString() == "13"){
            return false;
		}
});
}

function clearDiv(divID){
	$('textarea,input[type=text]', '#'+divID).val('');
	$('select', '#'+divID).val(0);
}

function removeDiv(fromID, objID){
    $('#'+objID, '#'+fromID).remove();
}

function addDiv(fromID, toID, basename, count, arrPattern ){
	var from = document.getElementById(fromID);
	var to = document.getElementById(toID);

	var divNew = document.createElement('div');
	var strDivName = basename + count;
	divNew.setAttribute('id',strDivName);
	var strHtml=from.innerHTML;

	for(strKey in arrPattern){
		strHtml=strHtml.replace(eval(strKey),arrPattern[strKey]);
	}

	divNew.innerHTML =strHtml;
	to.appendChild(divNew);
	clearDiv(strDivName);
	return strDivName;
}

function scrollDoor(){};
scrollDoor.prototype = {
	sd : function(menus,divs,openClass,closeClass){
		var _this = this;
		if(menus.length != divs.length){
			alert("菜单层数量和内容层数量不一样");
			return false;
		}
		for(var i = 0 ; i < menus.length ; i++){
			_this.$(menus[i]).value = i;
			_this.$(menus[i]).onmouseover = function(){
				for(var j = 0 ; j < menus.length ; j++){
					_this.$(menus[j]).className = closeClass;
					_this.$(divs[j]).style.display = "none";
				}
				_this.$(menus[this.value]).className = openClass;
				_this.$(divs[this.value]).style.display = "block";
			}
		}
		},
	$:function(oid){
		if(typeof(oid) == "string")	return document.getElementById(oid);
		return oid;
	}
}

// cookie start
function setCookie (name, value) {
    var exp = new Date();
    exp.setTime (exp.getTime() + 2*24*60*60*1000);
    document.cookie = name + "=" + escape(value) + "; expires=" + exp.toGMTString()+";path=/;";
}

function getCookie(name){
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return null;
}

function delCookie(name){
    var exp = new Date();
    exp.setTime(exp.getTime() + 2*24*60*60*1000);
    document.cookie = name + "=" + escape('') + "; expires=" + exp.toGMTString()+";path=/;";
}

var joboutsptr = '#';
var jobinnrsptr = '+';
var jobcookie = "Job_History";
var jobhistoryid = "jobhistoryid";

function setHistory(corpname, jobname, corpid, jobid, crttime) {
    var newlink = corpname + jobinnrsptr + jobname + jobinnrsptr + corpid + jobinnrsptr + jobid + jobinnrsptr + crttime;
    if(newlink == ''){return;}
    var jobhistory = getCookie(jobcookie);
    var newhistory = newlink;

    if(jobhistory != '' && jobhistory != undefined){
        var oldlink = jobhistory.split(joboutsptr);
        for(var i=0; i<5; i++){
            if(oldlink[i] != '' && oldlink[i] != undefined && oldlink[i] != newlink ){
                newhistory +=joboutsptr + oldlink[i];
            }
        }
    }
    setCookie(jobcookie, newhistory);
}

function showHistory()
{
    return showHistory2();
/*
    var jobhistory = getCookie(jobcookie);
    var content="";
    if(jobhistory != undefined && jobhistory != null && jobhistory != ''){
        var info = jobhistory.split(joboutsptr);
        for(var i=0; i<5; i++){
            if(info[i] != '' && info[i] != undefined){
                var urgs = info[i].split(jobinnrsptr);
                //var corpstr = "00" + urgs[2];
                var corpurl = '/'+ urgs[2] + '/';
                var days = pastDays(urgs[4]);
                if(days == 1){
                    var daystr = "今天发布</p>"
                }else{
                    var daystr = days + "天前发布</p>";
                }
                content += "<li><p ><a href=\""+corpurl+urgs[3]+".html\">"+urgs[1]+"</a> / "+daystr+"<p><a href=\""+corpurl+"\" class=\"corpLink\">"+urgs[0]+"</a></p></li>";
            }
        }
    }else{
        content = "您没有任何浏览纪录";
    }
    return content;
*/
}

function showHistory2()
{
    var jobhistory = getCookie(jobcookie);
    var content="";
    if(jobhistory != undefined && jobhistory != null && jobhistory != ''){
        var info = jobhistory.split(joboutsptr);
        for(var i=0; i<5; i++){
            if(info[i] != '' && info[i] != undefined){
                var urgs = info[i].split(jobinnrsptr);
                //var corpstr = "00" + urgs[2];
                var corpurl = '/'+ urgs[2] + '/';
                var days = pastDays2(urgs[4]);
                if(days == 0){
                    var daystr = "今天发布</p>"
                }else{
                    var daystr = days + "天前发布</p>";
                }
                content += "<li><p ><a href=\""+corpurl+urgs[3]+".html\">"+urgs[1]+"</a> / "+daystr+"<p><a href=\""+corpurl+"\" class=\"corpLink\">"+urgs[0]+"</a></p></li>";
            }
        }
    }else{
        content = "您没有任何浏览纪录";
    }
    return content;
}

function delHistory()
{
    delCookie(jobcookie);
    document.getElementById(jobhistoryid).innerHTML=showHistory();
};
// cookie end


//随机产生num个minInt-maxInt之间的不重复数
//排序,如果order=-1,则按从小到大排列,如果order为1则按从大到小排列,其他不改变顺序
function getRndNum(minInt, maxInt, num, order) {
    var num = parseInt(num);
    var numArr = new Array();
    if (num > maxInt - minInt + 1){
        for (i=minInt; i<maxInt; i++){
            numArr.push(i);
        }
        return numArr;
    }

    var tempnum = 1;
    numArr[tempnum-1] = Math.round(Math.random()*(maxInt-minInt))+minInt;
    if(num>1){
        do {
            var newInt = Math.round(Math.random()*(maxInt-minInt))+minInt;
            if (inArray(newInt, numArr) == -1){
                tempnum++;
                numArr[tempnum-1] = newInt;
            }
        } while (tempnum<num);
        if (order == -1){
            numArr.sort(new Function("a","b","return a-b;"));
        }
        if (order == 1){
            numArr.sort(new Function("a","b","return b-a;"));
        }
    }
    return numArr;
}

function showRelatedJob(jobid)
{
    var content="";
    if(typeof(jobType) != 'undefined'){
        var jobs = getRndNum(0, jobType.length, 5, -1);
        for(var i=0; i<jobs.length; i++){
            if(jobType[jobs[i]] instanceof Object){
                var job = jobType[jobs[i]];
                if(jobid == job['id']){
                    continue;
                }
                //var corpstr = "00" + job['corpid'];
                //var corpurl = "/"+corpstr.substr(corpstr.length - 2) + '/'+ job['corpid'] + '/';
                var corpurl = '/'+ job['corpid'] + '/';
                var days = pastDays(job['crttime']);
                if(days == 1){
                    var daystr = "今天发布</p>"
                }else{
                    var daystr = days + "天前发布</p>";
                }
                content += "<li><p ><a href=\""+corpurl+job['id']+".html\">"+job['title'].toHTML()+"</a> / "+daystr+"<p><a href=\""+corpurl+"\" class=\"corpLink\">"+job['name'].toHTML()+"</a></p></li>";
            }
        }
        if(content==""){
            content = "还没有其他同类职位";
        }
    }else{
        content = "还没有其他同类职位";
    }
    return content;
}

function showRelatedCorp(corpid)
{
    var content="";
    if(typeof(industryType) != 'undefined'){
        var corps = getRndNum(0, industryType.length, 5, -1);
        for(var i=0; i<corps.length; i++){
            if(industryType[corps[i]] instanceof Object){
                var corp = industryType[corps[i]];
                if(corpid == corp['id']){
                    continue;
                }
                //var corpstr = "00" + corp['id'];
                var corpurl = '/'+ corp['id'] + '/';
                content += "<li><p ><a href=\""+corpurl+"\">"+corp['name'].toHTML()+"</a> </p></li>";
            }
        }
        if(content==""){
            content = "还没有其他同类公司";
        }
    }else{
        content = "还没有其他同类公司";
    }
    return content;
}

function pastDays(time)
{
    if(time != '' || time != undefined){
        var st = time * 1000;
        var endTime = new Date();
        var et = endTime.getTime();
        var times = Math.abs(et-st);
        return  Math.ceil(times/(24*60*60*1000));
    }
}

function pastDays2(time){
    now = new Date();
    str = now.getYear() + "-";
    var mon = now.getMonth()+ 1;
    var day = now.getDate();
    str += mon >= 10 ? mon : ('0'+ mon);
    str += "-";
    str += day >= 10 ? day : ('0'+day);

    str = str.replace(/-/g, '');
    time = time.replace(/-/g, '');
    return parseInt(str)-parseInt(time);
}

function showNewJob()
{
    var content="";
    //var url = location.href.substr(0, location.href.lastIndexOf('/')+1);
    var arr = location.pathname.split('/');
    var url = '/'+arr[1]+'/';
    if(typeof(JobData) != 'undefined'){
    for(var i=0; i<8; i++){
        if(JobData[i] != undefined){
            var days = pastDays(JobData[i][2]);
            if(days == 1){
                var daystr = "今天发布</p></li>"
            }else{
                var daystr = days + "天前发布</p></li>";
            }
            content += "<li><p ><a href=\""+url+JobData[i][0]+".html\">"+(JobData[i][1]).toHTML()+"</a> / "+daystr;
        }
    }
    }
    return content;
}

function listJob(array)
{
    var content="<table cellspacing=\"0\"cellpadding=\"0\"border=\"0\"id=\"hiringtbl\"><tr class=\"theader\"><td>职位名称/发布日期</td><td width=\"150\">截止日期</td><td width=\"90\">工作地点</td><td width=\"80\">招聘人数</td></tr>";
    //var url = location.href.substr(0, location.href.lastIndexOf('/')+1);
    var url = '/'+location.pathname.replace(/\//ig,'')+'/';
    for(var i in array){
        if((array[i] != undefined) && (array[i]['crttime'] != undefined)){
            var days = pastDays(array[i]['crttime']);
            if(days == 1){
                var daystr = "今天发布"
            }else{
                var daystr = days + "天前发布";
            }
            if(array[i]['endtime'] == null || array[i]['endtime'] == 0){
                var endtime = '长期';
            }else{
                var endtime = array[i]['endtime'];
            }
            if(array[i]['amount'] == null || array[i]['amount'] == 0){
                var amount = '若干';
            }else{
                var amount = array[i]['amount'];
            }

            var title = array[i]['title'];
            if(title != undefined){
                title = title.toHTML();
            }

            content += "<tr><td><a href=\""+url+array[i]['id']+".html\" target=\"_blank\">"+title+"</a> / "+daystr+"</td>"
                    +"<td>"+endtime+"</td>"
                    +"<td>"+CityArea[array[i]['location']]+"</td>"
                    +"<td>"+amount+"</td></tr>";
        }
    }
    return content+"</table>";
}

function copyURL()
{
    var text=location.href+" "+document.getElementById('jobname').innerHTML;

    if (window.clipboardData){
        if(window.clipboardData.setData("Text", text)){
            alert('复制成功');
        }else{
            alert('复制失败');
        }
    }else{
        var flashId = 'flashId-HKxmj5';
        var clipboardSWF = '/clipboard.swf';

        if(!document.getElementById(flashId)){
            var div = document.createElement('div');
            div.id = flashId;
            document.body.appendChild(div);
        }
        document.getElementById(flashId).innerHTML = '';
        var content = '<embed src="' +
        clipboardSWF +
        '" FlashVars="clipboard=' + encodeURIComponent(text) +
        '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
        document.getElementById(flashId).innerHTML = content;
        alert('复制成功');
    }
}

function showDate(time)
{
    var date = new Date(time*1000);
    var y = date.getFullYear();
    var m = (date.getMonth()+1) < 10 ? '0'+(date.getMonth()+1).toString():(date.getMonth()+1);
    var d= date.getDate() < 10?'0'+(date.getDate()).toString():date.getDate();
	return (y+"-"+m+"-"+d);
}

function detailDate(time)
{
    var date = new Date(time*1000);
	return date.getFullYear()+"-"+((date.getMonth()+1) < 10 ? '0'+(date.getMonth()+1).toString():(date.getMonth()+1))+"-"+(date.getDate() < 10?'0'+(date.getDate()).toString():date.getDate())+" "+(date.getHours() < 10 ?'0'+(date.getHours()).toString():date.getHours())+":"+(date.getMinutes()<10?'0'+(date.getMinutes()).toString():date.getMinutes())+":"+(date.getSeconds()<10?'0'+(date.getSeconds()).toString():date.getSeconds());
}

function listSearch(array)
{
    var content="";
    var url = location.href.substr(0, location.href.lastIndexOf('qq.com')+6);
    if(array){
    for(var i = 0; i < array.length; i++) {
        if(array[i] != undefined){
            content += "<a href=\""+url+'/pub/post/list?'+array[i]['urlqry']+"&id="+array[i]['id']+"\">"+array[i]['name']+"</a>";
        }
    }
    }
    return content;
}

Request = function(url) {
    if(url){
        var param_str = url.match(/^\?([^#]*)\#?.*$/);
    }else{
        var param_str = window.location.search.match(/^\?([^#]*)\#?.*$/);
    }
	if(param_str != null && param_str[1] != undefined) {
		var param_arr = param_str[1].split('&');
		for(var i = 0; i < param_arr.length; i++) {
			var match = param_arr[i].split('=', 2);
			this.parameter[match[0]] = match[1];
		}
	}
}
Request.prototype = {
	parameter: {},
	get: function(paramName) {
		return this.parameter[paramName];
	},
	getInt: function(paramName) {
		var v = parseInt(this.get(paramName));
		return isNaN(v) ? 0 : v;
	}
}

function text_limit(element, total) {
    if ($(element).val().length > total) {
        $(element).val($(element).val().substr(0, total));
    }
    $("#f_total").text(total - $(element).val().length);
}

function inArray(val, arr){
    if(arr == null || arr == undefined){
        return -1;
    }
    for(var i = 0; i < arr.length; i++) {
        if(arr[i] == val){
          return i;
        }
    }
    return -1;
}

//*********************************************************************
if (window.T){
T.Loginout = function(){
    if (T.$('D_loginHref').innerText=='登录') {
        T.CreateLoginFrameWin();
    }else{
        T.LoadData('http://mng.qbar.qq.com/cgi-bin/cafecgi_mng_logout.cgi?'+Math.random(),T.OnLoginOut);
    }
}

T.LoadUserInfo = function(){
    T.LoadData('http://mng.qbar.qq.com/cgi-bin/cafecgi_mng_getsystime.cgi?'+Math.random(),T.OnLoginIn);
}

T.CheckUserLogin = function(){
    var uin=T.GetUIN();
    if(uin > 10000){
        T.LoadData('http://mng.qbar.qq.com/cgi-bin/cafecgi_mng_getsystime.cgi',function(R){
            if(R.sys_param.uin>10000)T.OnLoginIn(R);
            if(T.$('D_loginHref'))T.$('D_loginHref').style.visibility='visible';
            T.Reflow();
        });
    }
}

T.OnLoginIn = function(R){
    if (R) UIN_RESULT= R;
    try{
        T.$('D_loginHref').innerText = ' 退出';
        if(!T.$('D_userNickSpan'))return;
        T.$('D_userNickSpan').innerHTML="欢迎您，"+UIN_RESULT.sys_param.unick.toHTML();
    }catch(e){}
    try{
        var a = top.T.AfterLoginRC;
        if (a){
            a = new Function(a);
            a();
        }
    }catch(e){}

    window.setTimeout(function(){top.T.AfterLoginRC = ""},850);
    if(window.OnLoginSuccess&&!top.T.AfterLoginRC)window.setTimeout(function(){OnLoginSuccess(R,'slow')},500);
}
T.AfterLoginRC = "";
T.OnLoginOut = function(){
    T.$('D_userNickSpan').innerHTML = "已退出，再见";
    window.setTimeout(function(){T.$('D_userNickSpan').innerText=''},1000);
    T.$('D_loginHref').innerText = '登录';
    if(window.OnLogoutSuccess)window.OnLogoutSuccess();
}
}

//*********************************************************************
// post list
function showThisSearch() {
    var str = JobTime[$('#jobtime').val()];
    var title = $('#key_title').val().toHTML();
    if(title != '请输入关键词，如：建筑设计师'&& title != ''){
        str +=' + '+title;
    }

    if(($('#funtypename').val() != '') && ($('#funtypename').val() != '请选择')){
        str +=' + '+$('#funtypename').val();
    }
    str += ' + '+CityArea[$('#location').val()];
    str += ' + '+JobType[$('input[name=jobkind]:checked').val()];
    $('#thisSearch').html(str);
    return true;
}

function showThisSearch2() {
    var ft = $('#funtype').val();
    var jt = $('#jobtime').val();
    var lt = $('#location').val();
    var jk = $('input[name=jobkind]:checked').val();
    var keytype = $('input[name=key_type]:checked').val();

    var industry = $('#industry').val();
    var corptype = $('#corptype').val();
    var corpsize = $('#corpsize').val();
    var workyear = $('#workyear').val();
    var msalary = $('#msalary').val();
    var edulevel = $('#edulevel').val();

    var str = JobTime[jt];
    if($('#key_title').val() != '请输入关键词，如：建筑设计师' && $('#key_title').val() != ''){
        str += ' + '+ $('#key_title').val();
    }
    if(industry > 0){
        str += ' + '+Industry[industry]+'(行业)';
    }

    if(ft){
        if($('#funtypename').val() != ''){
            str +=' + '+$('#funtypename').val();
        }
    }

    if(corptype > 0){
        str += ' + '+CorpType[corptype];
    }
    if(corpsize > 0){
        str += ' + '+CorpSize[corpsize];
    }

    if(lt > 0){
        str += ' + '+CityArea[lt];
    }
    if(jk > 0){
        str += ' + '+JobType[jk];
    }

    if(workyear > 0){
        str += ' + '+WorkYear[workyear]+'(经验)';
    }
    if(msalary > 0){
        str += ' + '+MSalary[msalary];
    }
    if(edulevel > 0){
        str += ' + '+EduLevel[edulevel];
    }

    $('#thisSearch').html(str);
    return true;
}

var appliedJob = [];
var haveSaved = '';

function singleApply(id, corpid){
if(T.GetUIN() < 10000){
    T.Loginout();
}else{
    if(appliedJob.length == 0 || inArray(id, appliedJob) == -1) {
        $('#corpnameto').html($('#corp'+id).text().toHTML());
        $('#jobnameto').html($('#job'+id).text().toHTML());
        $('#recruitid').val(id);
        $('#corpid').val(corpid);
        doPopup('popupContact');
    }else{
        alert('申请已发出');
    }
}
}

function singleApply2(id, corpid){
if(T.GetUIN() < 10000){
    T.Loginout();
}else{
    if(appliedJob.length == 0 || inArray(id, appliedJob) == -1) {
        $('#corpnameto').html($('#corpname').text());
        $('#jobnameto').html($('#jobname').text());
        $('#recruitid').val(id);
        $('#corpid').val(corpid);

        doPopup('popupContact');
    }else{
        alert('申请已发出');
    }
}
}

var collectJob = [];
function batchCollect(){
if(T.GetUIN() < 10000){
    T.Loginout();
}else{
	if(!haveSelected('listform')){
	 	return false;
	}
    var tmpJob=[];
    var selected = false;
	$('input[type=checkbox]', '#listform').each(function(){
		if(this.checked == true){
            if(inArray(this.value, collectJob) > -1){
                this.checked = false;
            }else{
                selected = true;
                tmpJob.push(this.value);
            }
		}
	})
    if(selected == false){
        $("#select_all").attr('checked',false);
        alert('收藏成功');
        return true;
    }
	$("#listform").ajaxSubmit(function(R){
		try {
			eval('var RESULT='+R);
			if(RESULT.sys_param.ret_code == 0) {
                alert('收藏成功');
                $.each(tmpJob, function(i,n){
                    collectJob.push(n);
                });
                $("#select_all").attr('checked',false);

				clearAll('listform');
			}else{
                Ajax.showMsg(RESULT.sys_param.ret_code);
                if(RESULT.sys_param.ret_code == 4028){
                    location.href = "/user/user/show";
                }
            }
		} catch (e) {alert(e.message)}
	});
}
}

function saveSearch() {
if(T.GetUIN() < 10000){
    T.Loginout();
}else{
    var ft = $('#funtype').val();
    var jt = $('#jobtime').val();
    var lt = $('#location').val();
    var jk = $('input[name=jobkind]:checked').val();

    var url = '';
    if(ft != null && ft != 0){
        url += 'funtype='+ft;
    }
    if(jt != null && jt != 0){
        if(url == ''){
            url += 'jobtime='+jt;
        }else{
            url += '&jobtime='+jt;
        }
    }
    if(lt != null && lt != 0){
        if(url == ''){
            url += 'location='+lt;
        }else{
            url += '&location='+lt;
        }
    }
    if(jk != null && jk != 0){
        if(url == ''){
            url += 'jobkind='+jk;
        }else{
            url += '&jobkind='+jk;
        }
    }

    if($('#key_title').val() != '请输入关键词，如：建筑设计师'&& $('#key_title').val() != ''){
        url += '&key_title='+encodeURIComponent(($('#key_title').val()))+"&key_type="+$('#key_type').val()
    }

    if(haveSaved != '' && haveSaved == url){
        alert('保存成功');
        return false;
    }
    haveSaved = url;

    $("#urlqry").val(url);
    $("#savename").val($("#thisSearch").html());

	$("#saveform").ajaxSubmit(function(R){
		try {
			eval('var RESULT='+R);
			if(RESULT.sys_param.ret_code == 0) {
                var url = location.href.substr(0, location.href.lastIndexOf('qq.com')+6);
                $("#mySearchList").html($("#mySearchList").html()+ "<a href=\""+url+'/pub/post/list?'+haveSaved+"\">"+$("#thisSearch").html()+"</a>");
                alert('保存成功');
			}else{
                Ajax.showMsg(RESULT.sys_param.ret_code);
            }
		} catch (e) {alert(e.message)}
	});
}
}
function saveSearch2() {
if(T.GetUIN() < 10000){
    T.Loginout();
}else{
    var ft = $('#funtype').val();
    var jt = $('#jobtime').val();
    var lt = $('#location').val();
    var jk = $('input[name=jobkind]:checked').val();
    var keytype = $('input[name=key_type]:checked').val();

    var industry = $('#industry').val();
    var corptype = $('#corptype').val();
    var corpsize = $('#corpsize').val();
    var workyear = $('#workyear').val();
    var msalary = $('#msalary').val();
    var edulevel = $('#edulevel').val();
    var discuss = $('#discuss').attr('checked');

    var url = '';
    var str = '';
    if(jt > 0){
        url += 'jobtime='+jt;
    }
    if($('#key_title').val() != '请输入关键词，如：建筑设计师' && $('#key_title').val() != ''){
        url += '&key_title='+encodeURIComponent(($('#key_title').val()))+"&key_type="+keytype;
    }
    if(industry > 0){
        url += '&industry='+industry;
    }

    if(ft){
        url += '&funtype='+ft;
    }

    if(corptype > 0){
        url += '&corptype='+corptype;
    }
    if(corpsize > 0){
        url += '&corpsize='+corpsize;
    }
    if(lt > 0){
        url += '&location='+lt;
    }
    if(jk > 0){
        url += '&jobkind='+jk;
    }

    if(workyear > 0){
        url += '&workyear='+workyear;
    }
    if(msalary > 0){
        url += '&msalary='+msalary;
    }
    if(edulevel > 0){
        url += '&edulevel='+edulevel;
    }
    if(discuss == true){
        url += '&discuss='+1;
    }

    if(haveSaved != '' && haveSaved == url){
        alert('保存成功');
        return false;
    }
    haveSaved = url;

    $("#urlqry").val(url);
    $("#savename").val($("#thisSearch").html());

	$("#saveform").ajaxSubmit(function(R){
		try {
			eval('var RESULT='+R);
			if(RESULT.sys_param.ret_code == 0) {
                var url = location.href.substr(0, location.href.lastIndexOf('qq.com')+6);
                $("#mySearchList").html($("#mySearchList").html()+ "<a href=\""+url+'/pub/post/list?'+haveSaved+"\">"+$("#thisSearch").html()+"</a>");
                alert('保存成功');
			}else{
                Ajax.showMsg(RESULT.sys_param.ret_code);
            }
		} catch (e) {alert(e.message)}
	});
}
}


function addHover(){
    var trs=document.getElementById("searchResultList").getElementsByTagName("li");
    for(var i=0;i<trs.length;i++){
      trs[i].onmouseover=function(){this.className="hover";}
      trs[i].onmouseout=function(){this.className="";}
    }
}
// post list end

function changeBackGround(now) {
    var back = new Array("work_content", "user_content", "resume_content", "edu_content");
    for(var i=0; i < back.length; i++)
    {
        if(now == back[i]){
            $("#"+back[i]).css("background", "#EEF9FF");
        }else{
            $("#"+back[i]).css("background", "#F7F8FB");
        }
    }
}

// dynamicmenu
function addSort(obj) {
	if (obj.value == 'addoption') {
	var tt = obj;
	var ttop  = tt.offsetTop;
	var thei  = tt.clientHeight;
	var tleft = tt.offsetLeft;
	while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
	ttop  = ttop+thei+6 +'px';
	tleft = tleft+'px';

 	var newOptDiv = document.createElement('div');
 	newOptDiv.id = obj.id+'_menu';
 	newOptDiv.innerHTML = '<h5 style="font-size:14px;padding:3px 0 0 3px;color:#555;">添加分类</h5><a href="javascript:;" onclick="addOption(\'newsort\', \''+obj.id+'\')" class="float_del">关闭</a><div class="popupmenu_inner" style="text-align: center;">分类名称：<input type="text" name="newsort" size="10" id="newsort" style="width:150px;" /> <input type="button" name="addSubmit" value="创建" onclick="addOption(\'newsort\', \''+obj.id+'\')" style="border-top:#ddd 1px solid;border-right:#264fe6 1px solid;border-bottom:#264fe6 1px solid;border-left:#264fe6 1px solid;background:#2782d6;color:#fff;"/></div>';
 	newOptDiv.className = 'popupmenu_centerbox';
 	newOptDiv.style.cssText = 'position: absolute; left:'+tleft+'; top:'+ ttop+'; width: 400px; margin-left: -200px;';
 	document.body.appendChild(newOptDiv);
 	document.getElementById('newsort').focus();
 	}
}

function addOption(sid, aid) {
	var obj = document.getElementById(aid);
	var newOption = document.getElementById(sid).value;
	document.getElementById(sid).value = "";
	if (newOption!=null && newOption!='') {
		var newOptionTag=document.createElement('option');
		newOptionTag.text=newOption;
		newOptionTag.value="new:" + newOption;
		try {
			obj.add(newOptionTag, obj.options[0]); // doesn't work in IE
		} catch(ex) {
			obj.add(newOptionTag, obj.selecedIndex); // IE only
		}
		obj.value="new:" + newOption;
	} else {
		obj.value=obj.options[0].value;
	}
	// Remove newOptDiv
	var newOptDiv = document.getElementById(aid+'_menu');
	var parent = newOptDiv.parentNode;
	var removedChild = parent.removeChild(newOptDiv);
}
// dynamicmenu end
// Ajax
Ajax = function (){}
Ajax.onSuccess = null;
Ajax.onFailure = null;
Ajax.onError = function(){alert('系统错误');};
Ajax.showMsg = function(errCode){
	alert(Ajax.getMsg(errCode));
}

Ajax.getMsg = function(errCode){
	var msg = '未知错误: ErrCode='+errCode;
	switch (parseInt(errCode)) {
		case 0:	msg = '操作成功'; break;
		case 4001: msg = '对不起，输入信息错误或者缺失';break;
		case 4002: msg = '对不起，您没有权限进行该操作';break;
		case 4003: msg = '对不起，数据库操作失败';break;
		case 4004: msg = '对不起，该数据已存在';break;
		case 4009: msg = '对不起，系统内部错误';break;
		case 4011: msg = '对不起，请您先登录';break;
		case 4015: msg = '对不起，验证码校验失败';break;
        case 4016: msg = '对不起，公司帐号被锁定';break;
		case 4020: msg = '对不起，该操作为非法操作';break;
		case 4021: msg = '对不起，您的权限已过期';break;
		case 4022: msg = '对不起，文件类型错误';break;
		case 4023: msg = '对不起，文件尺寸超过范围';break;
		case 4024: msg = '对不起，找不到指定文件';break;
		case 4025: msg = '对不起，上传错误';break;
		case 4026: msg = '对不起，职位数已超过限制';break;
		case 4027: msg = '对不起，该活动已结束';break;
        case 4028: msg = '对不起，您的简历尚未完善';break;
        case 4029: msg = '对不起，请先注册';break;
	}
    return msg;
}

Ajax.result = function(R){
	if(R.sys_param.ret_code == 0){
		if(Ajax.onSuccess instanceof Function){
			Ajax.onSuccess(R.data);
		}else{
			Ajax.showMsg(R.sys_param.ret_code);
            if((R.sys_param.ret_code == 4011) && window.T){
                T.OnLoginOut();
            }
		}
	}else{
		if(Ajax.onFailure instanceof Function){
			Ajax.onFailure(R.sys_param.ret_code);
		}else{
			Ajax.showMsg(R.sys_param.ret_code);
		}
	}
}
//onSuccess just accept data, onFailure just accept the code
Ajax.get = function(url, param, onSuccess, onFailure){
	Ajax.onSuccess = onSuccess;
	Ajax.onFailure = onFailure;
	$.get(url, param, Ajax.result, 'json');
}
//onSuccess just accept data, onFailure just accept the code
Ajax.post = function(url, param, onSuccess, onFailure){
	Ajax.onSuccess = onSuccess;
	Ajax.onFailure = onFailure;
	$.post(url, param, Ajax.result,	'json');
}
// Show the DB data to form, the DB' field name as same as the form's
Ajax.show =function(data, form){
	$('#'+form).resetForm();
    if(data){
        $(':input', '#'+form).each(function(){
            if(this.type == 'checkbox'){
                var name = this.name.replace(/\[\]/, "");
                if(data[name] != undefined) {
                    var arr = data[name].split("&#");
                    for(key in arr){
                        if(this.value == arr[key]){
                            this.checked = true;
                        }
                    }
                }
            }else{
                if(data[this.name] != undefined){
                    $(this).val(data[this.name]);
                }
            }
        });
    }
}
// Ajax end

// popup
//0 means disabled; 1 means enabled;
var popupID = '';

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupID != ''){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("fast");
		$("#"+popupID).fadeIn("fast");
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupID !=''){
		$("#backgroundPopup").fadeOut("fast");
		$("#"+popupID).fadeOut("fast");
		popupID = '';
	}
}

//centering popup
function centerPopup(){
	//request data for centering
    //document.documentElement.clientWidth;
	var windowWidth = document.documentElement.clientWidth;//$(document).width();

    //document.documentElement.clientHeight;
	var windowHeight = document.documentElement.clientHeight;//$(document).height();

    var popupWidth = $("#"+popupID).width();
	var popupHeight = $("#"+popupID).height();

	//centering
	$("#"+popupID).css({
		"position": "absolute",
		"top": (windowHeight-popupHeight)/2 + document.documentElement.scrollTop,
		"left": (windowWidth-popupWidth)/2 + document.documentElement.scrollLeft
	});

    var h=document.documentElement.scrollHeight,h2=document.documentElement.clientHeight;
    if(h2>h)h=h2;
	//only need force for IE6
	$("#backgroundPopup").css({
		"height": h
	});
}

function doPopup(ID){
	if(popupID == ''){
		popupID = ID;
		centerPopup();
		loadPopup();
	}
}

//CONTROLLING EVENTS IN jQuery
this.tooltip = function(){
	/* CONFIG */
		xOffset = 10;
		yOffset = 20;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
	/* END CONFIG */
	$("a.tooltip").hover(function(e){
		this.t = this.title;
		this.title = "";
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$("#tooltip").remove();
    });
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
};

if($){
    $(document).ready(function(){
        //Click out event!
        /*
        $("#backgroundPopup").click(function(){
            disablePopup();
        });
        */
        //Press Escape event!
        $(document).keypress(function(e){
            if(e.keyCode==27 && popupID != ''){
                disablePopup();
            }
        });
        tooltip();
    });
}

function ShowMoreSearch(){
    var obj = document.getElementById("jobMoreSearch")
    if(obj.style.display=="none"){
        obj.style.display=""
        document.getElementById("jobSearchPic").src = "http://mat1.gtimg.com/cq/newjob/arrup.jpg"
        document.getElementById("jobSearchText").innerHTML = "隐藏更多搜索条件"
    }else{
        obj.style.display="none"
        document.getElementById("jobSearchPic").src = "http://mat1.gtimg.com/cq/newjob/arrdown.jpg"
        document.getElementById("jobSearchText").innerHTML = "显示更多搜索条件"
    }
}
function jobSubmitCheck() {
    if(document.searchform.key_title.value == '请输入关键词，如：建筑设计师'){
        document.searchform.key_title.value = '';
    }
    return true;
}
/*  |xGv00|4ebd45199e5089b2d8440d03a13bf492 */