﻿function SetCookie(sName,sValue,oExpires,sPath,sDomain,bSecure)
{
    var sCookie=sName+"="+encodeURIComponent(sValue);
    if(oExpires)
    {
        sCookie += "; expires="+oExpires.toGMTString();
    }
    if(sPath)
    {
        sCookie += "; path="+sPath;
    }
    if(sDomain)
    {
        sCookie += "; domain="+sDomain;
    }
    if(bSecure)
    {
        sCookie += "; secure";
    }
    document.cookie = sCookie;
}

function getCookie(sName)
{
    var sRE = "(?:;)?" + sName + "=([^;]*);?";
    var oRE = new RegExp(sRE);

    if(oRE.test(document.cookie))
    {
        return decodeURIComponent(RegExp["$1"]);
    }
    else
    {
        return null;
    }
}

function CenterScreen(width,height,scrollbars,resizable)
{
    var s;
    var w=(screen.width-width)/2;
    var h=(screen.height-height)/2;
    s="height="+height+",width="+width+",left="+w+",top="+h;
    if(scrollbars) s+=",scrollbars="+scrollbars;
    if(resizable) s+=",resizable="+resizable;
    return s;
}

function TableRowColor()
{
    var TR;
    if(document.getElementById("Info")!=null)
	TR = document.getElementById("Info").getElementsByTagName("tr");
    else if(document.getElementById("InfoList")!=null)
	{
	    TR=document.getElementById("InfoList").getElementsByTagName("tr");
	}
	else
	{
	    return;
	}
    if (TR != null && TR.length>2)  
    {  
        for (var i=0;i<TR.length;i++ )  
        {  
            TR[i].rowIndex%2==1?TR[i].style.backgroundColor="#E8F5FE":TR[i].style.backgroundColor="#FFF";
            TR[i].onmouseover=function(){this.style.backgroundColor="#F2FDDB";}
            TR[i].onmouseout=function(){this.rowIndex%2==1?this.style.backgroundColor="#E8F5FE":this.style.backgroundColor="#FFF";}
        }  
    }
}

function ChangeListColor()
{
	var li = document.getElementById("InfoList").getElementsByTagName("li");  
    if (li != null)  
    {  
        for (var i=0;i<li.length;i++ )  
        {  
            i%2==1?li[i].style.backgroundColor="#E8F5FE":li[i].style.backgroundColor="#FFF";
            li[i].onmouseover=function(){this.style.backgroundColor="#F2FDDB";}
            li[i].onmouseout=function(){for (var j=0;j<li.length;j++)j%2==1?li[j].style.backgroundColor="#E8F5FE":li[j].style.backgroundColor="#FFF";}
        }
    }
}

function Search()
{
if((type && (document.getElementById("txtKey").value.replace(" ","")=="" && document.getElementById("txtJob").value.replace(" ","")=="" && document.getElementById("txtAdd").value.replace(" ","")=="" )) || (!type && (document.getElementById("txtCName").value.replace(" ","")=="" && document.getElementById("txtCJob").value.replace(" ","")=="" && document.getElementById("txtCCon").value.replace(" ","")=="")))
{
CueShow(document.getElementById("SearchInfo"),"对不起！搜索条件至少要填定一项！");
return;
}
if(!type)
{
window.location="GetJobList.aspx?Name="+encodeURI(document.getElementById("txtCName").value) + "&CJob=" + encodeURI(document.getElementById("txtCJob").value) + "&Con=" + encodeURI(document.getElementById("txtCCon").value);
}
else
{
window.location="GetStudentList.aspx?Sp="+encodeURI(document.getElementById("txtKey").value) + "&Job=" + encodeURI(document.getElementById("txtJob").value) + "&Address=" + encodeURI(document.getElementById("txtAdd").value);
}
}

function CueShow(div,str)
{
div.innerHTML = "<div class=\"cue\" onmouseout=\"CueClose(this)\" onclick=\"CueClose(this)\">" + str + "</div>";
}

function CueClose(div)
{
div.style.height = "0";
div.innerHTML = "";
}


var type= getCookie("SearchType")=="true";
var login=getCookie("LoginType")=="true";

function SetSearch()
{
try
{
    if(type)
    {
    document.getElementById("StuSearch").style.display="block";
    document.getElementById("JobSearch").style.display="none";
    document.getElementById("InfoName").innerHTML="学生";
    }
    else
    {
    document.getElementById("StuSearch").style.display="none";
    document.getElementById("JobSearch").style.display="block";
    document.getElementById("InfoName").innerHTML="职位";
    }
}
catch(exception){}
}

function Info()
{
    if(!login)
    {
       window.open('CompanyReg.aspx?Han=Mod','',CenterScreen(500,470));
    }
    else
    {
       window.open('UserInfo.aspx','',CenterScreen(700,700,1,1));
    }
}

function Job()
{
    if(!login)
    {
       window.open('CompanyJob.aspx','',CenterScreen(600,500));
    }
    else
    {
       window.location='GetJobList.aspx';
    }
}

function GetJob(id)
{
    window.open('GetJobInfo.aspx?ID='+id,'',CenterScreen(600,500,1,1));
}

function GetStu(id)
{
    window.open('GetStudentInfo.aspx?No='+id,'',CenterScreen(600,700,1,1));
}

function SetLogin()
{
try
{
    if(login)
    {
    document.getElementById("LoginName").innerHTML="学生";
    document.getElementById("LoginInfo").innerHTML="学　号";
    document.getElementById("Reg").innerHTML="　　";
    }
    else
    {
    document.getElementById("LoginName").innerHTML="企业";
    document.getElementById("LoginInfo").innerHTML="企业名";
    document.getElementById("Reg").innerHTML="<a href=\"#\" onclick=\"window.open('CompanyReg.aspx','',CenterScreen(550,550))\" style=\"color:#AAA;\">注册</a>";
    }
}
catch(exception){}
}

window.onload=function(){TableRowColor();}

function btnChange_onclick() {
type=!type;
SetSearch();
SetCookie("SearchType",type,new Date("December 31, 2020"));
}

function btnLoginC_onclick() {
login=!login;
SetLogin();
SetCookie("LoginType",login,new Date("December 31, 2020"));
}




//title提示框
var pltsPop=null;
var pltsoffsetX = 10; // 弹出窗口位于鼠标左侧或者右侧的距离；3-12 合适
var pltsoffsetY = 15; // 弹出窗口位于鼠标下方的距离；3-12 合适
var pltsPopbg="#FFFFEE"; //背景色
var pltsPopfg="#111111"; //前景色
var pltsTitle="";
var bool=navigator.userAgent.indexOf("MSIE")>0;
document.write('<div id=\"pltsTipLayer\" style="display: none;position: absolute; z-index:10001"></div>');
function pltsinits()
{
if(bool)
{
document.onmouseover = plts;
document.onmousemove = moveToMouseLoc;
}
}
function plts()
{
if(bool)
{
var o=event.srcElement;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
pltsPop=o.dypop;
if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined")
{
pltsTipLayer.style.left=-1000;
pltsTipLayer.style.display='';
var Msg=pltsPop.replace(/\n/g,"<br/>");
Msg=Msg.replace(/\0x13/g,"<br/>");
var re=/\{(.[^\{]*)\}/ig;
if(!re.test(Msg))pltsTitle="<label style=\"color:#ffffff\">简介</label>";
else{
re=/\{(.[^\{]*)\}(.*)/ig;
pltsTitle=Msg.replace(re,"$1")+" ";
re=/\{(.[^\{]*)\}/ig;
Msg=Msg.replace(re,"");
Msg=Msg.replace("<br>","");}
var content =
"<dl id=\"toolTip\" style=\"FILTER:alpha(opacity=85);padding:2px;background:#fff;\"><dd id=\"pltsPoptop\" class=\"toolTipTitle\" style=\"line-height:20px;\"><p id=\"topleft\" class=\"left\"><b><label style=\"color:#ffffff\">↖</label>"+pltsTitle+"</b></p><p id=\"topright\" class=\"right\" style=\"display:none\"><b>"+pltsTitle+"<label style=\"color:#ffffff\">↗</label ></b></p></dd><dd class=\"toolTipMsg\">"+Msg+"</dd><dd id=\"pltsPopbot\" style=\"display:none\" class=\"toolTipTitle\"><p id=\"botleft\" class=\"left\"><b><label style=\"color:#ffffff\">↙</label >"+pltsTitle+"</b></p><p id=\"botright\" class=\"right\" style=\"display:none\"><b>"+pltsTitle+"<label style=\"color:#ffffff\">↘</label></b></p></dd></dl>";
pltsTipLayer.innerHTML=content;
toolTip.style.width=Math.min(pltsTipLayer.clientWidth,document.documentElement.clientWidth/2.2);
moveToMouseLoc();
return true;
}
else
{
pltsTipLayer.innerHTML='';
pltsTipLayer.style.display='none';
return true;
}
}
}

function moveToMouseLoc()
{
if(bool)
{
if(pltsTipLayer.innerHTML=='')return true;
var MouseX=event.clientX;
var MouseY=event.clientY;
//window.status=event.y;
var popHeight=pltsTipLayer.clientHeight;
var popWidth=pltsTipLayer.clientWidth;

if(MouseY+pltsoffsetY+popHeight>document.documentElement.clientHeight)
{
popTopAdjust=-popHeight-pltsoffsetY*1.5;
pltsPoptop.style.display="none";
pltsPopbot.style.display="";
}
else
{
popTopAdjust=0;
pltsPoptop.style.display="";
pltsPopbot.style.display="none";
}
if(MouseX+pltsoffsetX+popWidth>document.documentElement.clientWidth)
{
popLeftAdjust=-popWidth-pltsoffsetX*2;
topleft.style.display="none";
botleft.style.display="none";
topright.style.display="";
botright.style.display="";
}
else
{
popLeftAdjust=0;
topleft.style.display="";
botleft.style.display="";
topright.style.display="none";
botright.style.display="none";
}
pltsTipLayer.style.left=MouseX+pltsoffsetX+document.documentElement.scrollLeft+popLeftAdjust;
pltsTipLayer.style.top=MouseY+pltsoffsetY+document.documentElement.scrollTop+popTopAdjust;
return true;
}
}
pltsinits();