﻿function LoginSubmit()
{
    if($("user").value=="")
    {
        $("user").focus();
        alert("请输入用户名!");
        return;
    }
    if($("password").value=="")
    {
        alert("请输入密码!");
        $("password").focus();
        return;
    }
	AjaxMethod("/Ajax/Login.ashx", "post", "u=" + escape($("user").value) + "&p=" + escape($("password").value), LoginCallBack);

}

function LoginCallBack(ajax)
{
    var domain = document.domain.toLowerCase().replace("www.", "");
    var retval = ajax.responseText;
    var re = new RegExp("<script.*script>", "ig");
    retval = retval.replace(re, "");
    re = new RegExp("\\s*", "ig");
    retval = retval.replace(re, "");
    switch(retval)
    {
        case "N1":
            alert("参数错误！");
            break;
        case "N2":
            alert("登录失败，请确认用户名和密码是否正确或者注册信息是否通过审核！");
            break;
        case "N3":
            alert("登录失败");
            break;
        case "C1":
            //top.location.href="http://ehr." + domain;
			top.location.href = "http://" + domain + "/Industry/";
            break;
        case "C2":
            //top.location.href="http://ehr." + domain;
			top.location.href = "http://" + domain + "/Industry/companyinfo.aspx";

            break;
        case "P1":
            //top.location.href = "http://myjob." + domain;
			top.location.href = "http://" + domain + "/Person/";
            break;
        case "P2":
            //top.location.href = "http://myjob." + domain + "/resume.aspx";
			top.location.href = "http://" + domain + "/Person/resumeinfo.aspx";
            break;
        default:
            if(retval.split(":")[0]=="Redir"){top.window.location.href=retval.substring(retval.indexOf(":")+1);return;}
            alert("未知的消息");
            break;
    }
}

function Reg()
{
    if($("t").value=="")
    {
        alert("请选择用户类别");
        $("t").focus();
        return;
    }
    if($("t").value=="C")
        top.location.href = "/User/Company_Reg.aspx";
    else
        top.location.href = "/User/Person_Reg.aspx";
}

function getPass()
{
    wopen("/User/GetPassWord.aspx",450,300,400,300);
}


//获取用户IP
function GUIP(id)
{
	//缓存
    if(!window.Cache)
    {
        window.Cache = new Object();
    }
    if(window.Cache[id]!=null)
    {
	    alert(window.Cache[id]);
    }
    else
    {
        AjaxMethod("/Ajax/Ajax.ashx?method=getUserIP", "post", "id=" + id, GUIPCallBack, id);
    }
}
//获取用户IP
function GUIPCallBack(ajax, id)
{
    alert(ajax.responseText);
    window.Cache[id] = ajax.responseText;
}
//登录信息
function LoginInfo()
{
    if(getCookie("qiXdE4kmn3j4%2fzoNHMOf1w%3d%3d")!=null)
        AjaxMethod("/Ajax/Ajax.ashx", "post", "method=LoginInfo", function(ajax){$("Info").innerHTML=ajax.responseText;$("Info").style.lineHeight="25px"});
    $("Info").style.display="";
}

function A(id)
{
    __getAreaNameFromValue(id);
}
function S(id, type)
{
    __getSysCodeFromValue(id, type);
}

function getCookie(name)
{
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return getCookieVal (j);

        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
function getCookieVal (offset)
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}
function getAllAreaCode(code)
{
    var myName = __getAreaCodesName(code);
    var myCode = __getAreaCodesID(code);
    var retName = [], retCode = [];
    
    for(var i=1;i<myCode.length;i++)
    {
        if(myCode[i].substr(4)=="00")
        {
            var tmp = __getAreaCodesName(myCode[i]);
            for(var j=1;j<tmp.length;j++)
                tmp[j] = "　" + tmp[j];
            retName = retName.concat(tmp);
            retCode = retCode.concat(__getAreaCodesID(myCode[i]))
        }
        else
        {
            retName = retName.concat(new Array(myName[i]));
            retCode = retCode.concat(new Array(myCode[i]));
        }
    }
    retName.unshift(myName[0]);retCode.unshift(myCode[0]);
    return {"Name":retName, "Code":retCode};
}
function SearchSub()
{
    var t = $("ST").value;
    var k = $("SK").value;
    var s = $("SS").value;
    var a = $("SA").value;
    var qu = new Array();
	qu[qu.length]="k=" + escape(k.trim()).replace(/\#/g,"%EF%BC%83").replace(/\+/g,"%EF%BC%8B");//escape(k.trim());
	qu[qu.length]="s=" + s;
	qu[qu.length]="a=" + a;
	qu[qu.length]="page=1";
    var url = "";
    switch(t)
    {
        case "J":
            url = "/JobSearchList.aspx";
            break;
        case "P":
            url = "/ResumeSearchList.aspx";
            break;
        case "C":
            url = "/CompanySearchList.aspx";
            break;
    }
    top.location.href = url + "?" + qu.join("&");
}

function SearchChange(v)
{
    switch(v)
    {
        case "J":
            Forms.initDropList($("SS"),__getSysCodesName("18000"),__getSysCodesID("18000"),QueryString("s"),"职位类别不限","");
            $("SS").style.display="none";
            if($("s_90") && location.href.substr(location.href.length-1, 1)=="/")$("s_90").style.display='';
            break;
        case "P":
            Forms.initDropList($("SS"),new Array('男','女'),new Array('1','2'),"","性别不限","0");
            $("SS").style.display="";
            if($("s_90") && location.href.substr(location.href.length-1, 1)=="/")$("s_90").style.display='none';
            break;
        case "C":
            Forms.initDropList($("SS"),__getSysCodesName("19000"),__getSysCodesID("19000"),QueryString("s"),"行业类别不限","");
            $("SS").style.display="";
            if($("s_90") && location.href.substr(location.href.length-1, 1)=="/")$("s_90").style.display='none';
            break;
    }
}

function setCss(id, css)
{
    if(css == undefined)css="i_navy_ing";
    if($(id))$(id).className = css;
}

function createDiv()
{
	var oDiv = document.getElementById("tips");
	if(oDiv==null)
	{
		oDiv = document.createElement("div");
		oDiv.id="tips";
		oDiv.className = "ts";
		oDiv.style.position="absolute";
		document.body.appendChild(oDiv);
		oDiv.style.zIndex = 1000;
	}
	return oDiv;
}
function showJobs(e, id)//显示招聘职位
{
    if(document.readyState!="complete")return;
	var oDiv = createDiv();
	if(!window.Cache)window.Cache = new Object();
    window.E = e.srcElement || e.target;
	if(window.Cache["C_" + id]!=null)
	{
	    showJobsCallBack(window.Cache["C_" + id], id);
	}
	else
	{
        AjaxMethod("/Ajax/CompanyJobNameList.aspx", "get", "id=" + id, showJobsCallBack, id);
    }
}
function showJobsCallBack(ajax, id)
{
	if(document.readyState!="complete")return;
	var e = window.E || window.event;
	var oDiv = createDiv();
	var inp = typeof(ajax)=="object"?ajax.responseText:ajax;
	oDiv.innerHTML = inp;
	oDiv.style.display = "";
	
    if(document.all)
        oDiv.style.filter = "Alpha(Opacity=20)";
    else
        oDiv.style.opacity = "0.2";
    oDiv.title="20";
    setTimeout('setOpacity()',10);

	var pos = getAbsolutePosition(window.E);
	oDiv.style.left = pos.left + "px";
	oDiv.style.top = (pos.top + pos.height) + "px";
	window.Cache["C_" + id] = inp;
}
function setOpacity()
{
    var oDiv = createDiv();
    var opacity=parseInt(oDiv.title);
    opacity += 20;
    oDiv.title = opacity;
    
    if(document.all)
        oDiv.style.filter = "Alpha(Opacity=" + opacity + ")";
    else
        oDiv.style.opacity = opacity / 100;
        
    if(opacity<100)setTimeout('setOpacity()',10);
}
function hideTip()
{
	var oDiv = document.getElementById("tips");
	if(oDiv)
	{
		oDiv.style.display = "none";
	}
}


