/**************************
 * 首页滑过城市站点变更样式和图片[v6]
 * author: yanf
 * date  : 2009-5-12
 * changeCssAndImg: 公用函数[/js/city/index.js]
 */
function hourCity(obj, cssName, imgStr){
	imgStr = "/city/index/images/big_"+imgStr+".png";
	changeCssAndImg(obj, cssName, "centerImg", imgStr);
}

/**************************
 * 首页搜索展开层
 * author: yanf
 * date  : 2009-5-12
 */
function clickOper(oper){
	var expand = document.getElementById("expand");
	if(oper == "down"){
		expand.style.visibility = "visible";
	}else if(oper == "up"){
		expand.style.visibility = "hidden";
	}
}

/**************************
 * 首页搜索选择工作地点
 * author: yanf
 * date  : 2009-5-12
 */
function clickCity(){
	var imagedegree = document.getElementById("imageworkyear");
	initLayer(false,"joblocation","add",imagedegree,0,"工作地点");
}

/**************************
 * 首页搜索点击选择条件按钮
 * author: yanf
 * date  : 2009-5-12
 */
function clickOption(option){
	if(option.opt4 != ""){
		initLayer(option.opt1,option.opt2,option.opt3,$(option.opt4),option.opt5,option.opt6);
	}
}

/**************************
 * 首页登陆切换会员类型
 * date  : 2009-5-20
 */
function userType(types)
{
    var m=document.userFormLogin;
	if(typeof(m.type)=="object")
	{
		if(types=="false")          //个人会员
		{
			document.userFormLogin.type[0].checked=true;
			document.getElementById("corRegedit").style.display = "";
			document.getElementById("checkID").style.display="none";
		}
		else if(types=="true")      //企业会员
		{
		    document.getElementById("corRegedit").style.display = "none";
			document.getElementById("checkID").style.display="";
			document.userFormLogin.type[1].checked=true;
		}
	}
}

/**************************
 * 首页登陆
 * date  : 2009-5-20
 */
function userLogin()
{
    var form1 = document.userFormLogin;
	if(form1.username.value.replace(/(^\s*)|(\s*$)/g, "")==""){
	    form1.error.value = "用户不能为空";
		form1.classic.value = "user";
	    if(form1.type[0].checked == true){
	        form1.action=personDomain+"/process/person/login.jsp";
	    }else{
	        form1.action=companyDomain+"/process/company/login.jsp";
	    }
		form1.submit();
		return false;
	}
	if(ischinese2(form1.username.value)){
        form1.error.value = "对不起,不支持中文帐号！";
        form1.classic.value = "user";
        if(form1.type[0].checked == true){
        	form1.action=personDomain+"/process/person/login.jsp";
        }else{
            form1.action=companyDomain+"/process/company/login.jsp";
        }
		form1.submit();
		return false;
	}
	if(form1.password.value==""){
	    form1.error.value = "用户密码不能为空";
	    form1.classic.value = "pass";
	    if(form1.type[0].checked == true){
	    	form1.action=personDomain+"/process/person/login.jsp";
	    }else{
	    	form1.action=companyDomain+"/process/company/login.jsp";
	    }
		form1.submit();
		return false;
	}
	if(form1.type[1].checked == true){
	    if(form1.authcode.value == ""){
		    form1.error.value = "验证码不能为空";
		    form1.classic.value = "authcode";
		    form1.action=companyDomain+"/process/company/login.jsp";
			form1.submit();
			return false;
	    }
	}
	document.getElementById("imgLogin").src= "/process/website/images/index_nlogin_2.gif";
	document.getElementById("imgLogin").style.cursor="default";
	document.getElementById("imgLogin").disabled=true;
	form1.target="_self";
	if(form1.type[0].checked == true){
		form1.action=personDomain+"/Login.shtml";
	}else{
		form1.action=companyDomain+"/Login.shtml";
	}
	form1.submit();
}

/**************************
 * 首页登陆切换验证码
 * author: yanf
 * date  : 2009-5-20
 */
function changeauthcodePic()
{
	var obj = document.getElementById("authcodePic");	
	obj.src='/process/online/company/AuthCodeCreator.jsp?math='+Math.random();
}

/**************************
 * 首页加载职位文件
 * author: yanf
 * date  : 2009-5-20
 */
function loadSitePosition(name, cursel, cssStr, site){
	//jobContent.innerHTML = "<img src='/process/online/images/loading.gif' border='0' align='absmiddle'/>数据加载中...请稍候...";
	for(var i=1; i<=11; i++){
		var menu = $(name+"_"+i);
		menu.className = (i==cursel?cssStr:"");
	}
	loadStaticData("/city/index/include/loadStaticFile.jsp?type=job&site="+site, {container:"jobContent"});
}

/**************************
 * 首页加载求职E、领秀卡、招聘会预告
 * author: yanf
 * date  : 2009-5-20
 */
function loadPic(name, cursel, cssStr, fileName){
	var url = "/city/index/include/loadStaticFile.jsp?type=pic&name="+fileName;
	for(var i=1; i<=3; i++){
		var menu = $(name+"_"+i);
		menu.className = (i==cursel?cssStr:"");
	}
	if(cursel == 1){
		url = "/city/index/include/loadStaticFile.jsp?type=market";
		loadStaticData(url, {onComplete: callPicStart});
	}else if(cursel == 3){
		var url = "/city/index/include/loadStaticFile.jsp?type=zccd";
		loadStaticData(url, {onComplete: callZccdStart});
	}else{
	    loadStaticData(url, {onComplete: callPicStop});
	}
}

function callPicStart(findreq){
	$("zccdContent").style.display = "none";
	$("picContent").style.display = ""; 
	$("picContentHid").style.display = "none";
}

function callZccdStart(findreq){
	$("zccdContent").style.display = "";
	$("picContent").style.display = "none";
	$("picContentHid").style.display = "none";
}

function callPicStop(findreq){
	$("picContent").style.display = "none";
	$("picContentHid").innerHTML = findreq.responseText.trim();
	$("picContentHid").style.display = "";
	$("zccdContent").style.display = "none";
}

function searchKeyDown()
{
	if(window.event.keyCode==13)
	{
		 submitsearch();
	}
}

function submitsearch()
{
    var m = document.queryForm;

    if(m.key.value.trim().length==0 || m.key.value=="请输入关键字……")
	{
		Wtip.disWTip({obj:m.key,str:'请输入关键字!',wid:130,wTop:140,wLeft:0});
		m.key.focus();
	    return false;
	}else if(m.key.value.trim().length > 30){
		Wtip.disWTip({obj:m.key,str:'不能超过30个字符!',wid:130,wTop:140,wLeft:0});
		m.key.focus();
	    return false;
	}
	m.action= searchDomain +"/Search.shtml?type=JobSearch";
	m.submit();
}

/**在用户表单回车或Tab*/
function userKeyDown(event)
{
	if(!window.event) window.event=event;
	if(window.event.keyCode==13)
	{
		document.userFormLogin.password.focus();
		return false;
	}
 }

/**在密码表单回车或Tab*/
function passKeyDown(event)
{
	if(!window.event) window.event=event;
	if (window.event.keyCode==13)
	{	
		if(document.userFormLogin.type.length > 1){
			if (document.userFormLogin.type[0].checked)					//选择个人会员
			{
			  	userLogin();
			}
			if(document.userFormLogin.type[1].checked)					//选择企业会员
			{
			  	document.userFormLogin.authcode.focus();
			}
	    }else{
			userLogin();
	    }
	}
}

/**在验证码上表单上回车*/
function codeKeyDown(event)
{
	if(!window.event) window.event=event;
	if(window.event.keyCode==13)
	{
  		userLogin();
	}
}

/**
 *判断是否中文函数m,本来在strUtil.js中已经有这个js方法，但在firefox1.0中无法取得，为此加入本方法
 */
function ischinese2(s){
    var ret=false;

    for(var i=0;i<s.length;i++){
        if(s.charCodeAt(i)>=256){			
			ret=true;
			break;
		}
	}

    return ret;
}

function setFestivalBg()
{
	if(document.getElementById("chinaTop").className=="china09101"){
		document.getElementById("chinaTop").className = "china09101_2";
		document.getElementById("reSyleId").className="";
		document.getElementById("chinaback").className="";
		document.getElementById("indexBgId").display="none";
	}
}

function closeStyle(){
	var div1 = document.getElementById("chinaDiv1");
	var div2 = document.getElementById("chinaDiv2");
	var closeBtn = document.getElementById("closeBtn");
	closeBtn.style.display = "none";
	div1.className = "china09101_2";
	div2.className = "";
}
