﻿//全角２半角

function CtoH(obj)
{
            var str=obj.value;
            var result="";
            for (var i = 0; i < str.length; i++)
            {
            if (str.charCodeAt(i)==12288)
            {
            result+= String.fromCharCode(str.charCodeAt(i)-12256);
            continue;
            }
            if (str.charCodeAt(i)>65280 && str.charCodeAt(i)<65375)
            result+= String.fromCharCode(str.charCodeAt(i)-65248);
            else result+= String.fromCharCode(str.charCodeAt(i));
            }
            obj.value=result;
}

function checkHeadText(textid)
{
           if(document.getElementById(textid).value=="请输入您感兴趣的公司或职位名称")
           {
                document.getElementById(textid).value="";
              //alert("请输入关键字！");
              return true;
           }
           else
           {
             return true;
           }
}
function textCounter(field, maxlimit){
    if (field.value.length > maxlimit) {
        field.value = unescapeHTML(escapeHTML(field.value).substring(0, maxlimit));
    }
}

function escapeHTML(text){
    text = text.replace('&', '&amp;');
    text = text.replace('<', '&lt;');
    text = text.replace('>', '&gt;');
    return text;
}

function unescapeHTML(text){
    text = text.replace('&amp;', '&');
    text = text.replace('&lt;', '<');
    text = text.replace('&gt;', '>');
    return text;
}
function Nav(){
    if(!document.getElementById("m-nav")){
        return;
    }
    var mNav = document.getElementById("m-nav");
    navA = mNav.getElementsByTagName("a");
    for (var i = 0; i < navA.length; i++) {
        if (navA[i].getAttribute("Nav")) {
            navA[i].onmouseover = function(){
                var navC = document.getElementById(this.getAttribute("Nav") + "_c");
                navC.style.display = "block";
                navC.style.left = this.offsetLeft + "px";
                navC.onmouseover = function(){
                    this.style.display = "block";
                    this.onmouseout = function(){
                        this.style.display = "none";
                    }
                }
                this.onmouseout = function(){
                    navC.style.display = "none";
                }
            }
        }
    }
}
function getWH(){
    if(!document.getElementById("covering")){
        return;
    }
    var bodyWidth = document.body.clientWidth;
    var bodyHeight = document.body.clientHeight;
    document.getElementById("covering").style.width = bodyWidth + "px";
    document.getElementById("covering").style.height = bodyHeight + "px";
}
function clearTxt(){ //清除搜索框里面的关键字
    var Input=document.getElementsByTagName("input");
    for(var i=0;i<Input.length;i++){    
        if(Input[i].getAttribute("type")!="text"){
            continue;
        }
        if(Input[i].getAttribute("type")=="text"){
            if(Input[i].className=="s-txt" || Input[i].className=="txt"){
                Input[i].onclick=function(){
                    if (this.value=="请输入您感兴趣的公司或职位名称") {
                        this.value="";
                    }
                }
            }
        }
    }
}

function hoverjoblist(){
    if(!document.getElementById("jobList")){
        return;
    }
    var joblist=document.getElementById("jobList").getElementsByTagName("li");
    for(var i=0;i<joblist.length;i++){
        joblist[i].onmouseover=function(){
            this.style.backgroundColor="#EDF2FA";
        }
        joblist[i].onmouseout=function(){
            this.style.backgroundColor="";
        }
    }
}

function hoverTable(){
    var tableList=document.getElementsByTagName("table");
    var rowList=null;
    var tblist=null;
    for(var i=0; i<tableList.length; i++){
        if(!tableList[i].getAttribute("id")){
            continue;
        }
        if(tableList[i].className=="pingjiaTB"){
            continue;
        }
        rowList=tableList[i].getElementsByTagName("tr");
        for(var j=1; j<rowList.length; j++){
            rowList[j].onmouseover=function(){
                this.style.backgroundColor="#efefef";
                this.onmouseout=function(){
                    this.style.backgroundColor="";
                }
            }            
        }
    }
}

//企业登录中
function campanyLoading(){
    var frame=document.createElement("iframe");
    var cssStr="position:absolute;left:0;top:0;"
    frame.style.cssText=cssStr+"width:100%;height:100%;background:#999;filter:alpha(opacity=40);opacity:0.40;";
    document.body.appendChild(frame);
    var div=document.createElement("div");
    div.style.cssText=cssStr+" padding-left: 45%; padding-top: 20%;";
    div.innerHTML="<p>正在登录，请稍候...</p><img src='../images/loading.gif' alt='加载中' />";
    document.body.appendChild(div);
}
//页面加载完后执行函数
function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}
addLoadEvent(Nav);
addLoadEvent(getWH);
addLoadEvent(clearTxt);
addLoadEvent(hoverjoblist);
addLoadEvent(hoverTable);
