﻿$(function(){
	$(".head_nav li").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	$(".head_nav li").click(function(){
		$(".head_nav li").removeClass("active");
		$(this).addClass("active");
	})
});

/*$(function(){
	var nowpx = 0;
	function listup(){
		//listup();
		nowpx=nowpx-25;
		c_px = nowpx+'px';
		if (nowpx-25==25) {
			nowpx==-275
		}
		else if(nowpx-25==-225) {
			nowpx=25
		}
		$("#topnews_list").css("top",c_px);
		
	}
	function listdown(){
		//listup();
		nowpx=nowpx-25;
		c_px = nowpx+'px';
		if (nowpx-25==-250) {
			nowpx=25
		}
		$("#topnews_list").css("top",c_px);
	}
	$("#icon_arrow_blue_up").click(function(){
		listup()
	})
	
	$("#icon_arrow_blue_down").click(function(){
		listdown()
	})
})*/

//首页焦点轮播
function frontpage_pic(){

		var curIndex=0; 
		//时间间隔 单位毫秒 
		var timeInterval=2500; 
		var arr=new Array(); 
		arr[0]="images/frontpage/fp_mainleft_pic_a.jpg"; 
		arr[1]="images/frontpage/fp_mainleft_pic_b.jpg"; 
		setInterval(changeImg,timeInterval); 
		function changeImg() 
		{ 
		var obj=document.getElementById("view"); 
		if (curIndex==arr.length-1) 
		{ 
		curIndex=0; 
		} 
		else 
		{ 
		curIndex+=1; 
		} 
		obj.src=arr[curIndex]; 
		} 

};

$(function(){

		$(".head_search_select_option li").hover(function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		})
		
		$(".head_search_select").click(function(){
			$(".head_search_select .head_search_select_optionbox").show();
		});
		$(".head_search_select .head_search_select_option").hover(function(){
			$(".head_search_select .head_search_select_optionbox").show();
		},function(){
			$(".head_search_select .head_search_select_optionbox").hide();
		});

	
	$(".head_search_select_option li").click(function(){
		$("#choosecity").html($(this).html());
		var rid = parseInt($(this).attr("id").substring(1));
		$("#regionid").val(rid);
		
	});
});

$(function(){
	$("#quicksearch-city-all").hide();
	$("#quicksearch-city-hot").show();
	$("#enter-quicksearch-city-all").click(function(){
		$("#quicksearch-city-all").show();
		$("#quicksearch-city-hot").hide();
	});
	$("#enter-quicksearch-city-hot").click(function(){
		$("#quicksearch-city-all").hide();
		$("#quicksearch-city-hot").show();
	});
})

$(function(){
		$(".tabs_c2").hide();
		$(".tabs_c3").hide();
		$(".tabs_list_c2").hide();
		$(".tabs_list_c3").hide();
		$(".indextabs li").hover(function(){
				$(".indextabs li").removeClass("active");
				$(this).addClass("active");
		});
		$("#tabs_c1").hover(function(){
				$(".tabs_c").hide();
				$(".tabs_list").hide();
				$(".tabs_c1").show();
				$(".tabs_list_c1").show();
		});
		$("#tabs_c2").hover(function(){
				$(".tabs_c").hide();
				$(".tabs_list").hide();
				$(".tabs_c2").show();
				$(".tabs_list_c2").show();
		});
		$("#tabs_c3").hover(function(){
				$(".tabs_c").hide();
				$(".tabs_list").hide();
				$(".tabs_c3").show();
				$(".tabs_list_c3").show();
		});
});

$(function(){
	$(".index_iconbox_floatlayer").hide();
	$(".indexicon").hover(function(){
		$(this).parent().find(".index_iconbox_floatlayer").show();
	},function(){
		$(this).parent().find(".index_iconbox_floatlayer").hide();
	})
})

function gotoPage(objId, maxPage, url){
	var objVal = $("#" + objId).val();
	var page = parseInt(objVal);
	if(isNaN(page)){
		page = 1;
	}
	if(page < 1){
		page = 1;
	}
	if(page > maxPage){
		page = maxPage;
	}
	self.location.href = url + '=' + page;
}
var curMsgIndex = 0;
function nextMsg(){
	var count = $("#msg_count").val();
	curMsgIndex++;
	if(curMsgIndex >= count){
		curMsgIndex = 0;
	}
	$("#msg_show").html($("#msg_" + curMsgIndex).html());
}
function preMsg(){
	var count = $("#msg_count").val();
	curMsgIndex--;
	if(curMsgIndex < 0){
		curMsgIndex = count - 1;
	}	
	$("#msg_show").html($("#msg_" + curMsgIndex).html());
}
function headerSearch(th){
	var key = $("#searchkey").val();
	var rid = $("#regionid").val();
	if(key == '职位信息 如：销售助理'){
		th.form.action = '/search/';
		th.form.target = '_blank';
		th.form.submit();
	}else{
		th.form.target = '_blank';
		th.form.action = '/search/infos.php';
		th.form.submit();
	}
	
	
	//location.href = "/info/?key=" + key + "&region=" + rid;
}
function initUserReg(){
	obj = $("#myform").validate({
		rules:{
			username:{ required: true,  minlength: 4,  maxlength: 20, remote: "chk.php"  },
			password:{ required: true, minlength: 6 },
			chkpass:{ required: true, equalTo: "#password" },
			orgname:{ required: true },
			email:{ required: true, email:true, remote: "chk.php?type=1" },
			businessname:{ required: true },
			phone:{ required: true },
			mobile:{ required: true }
		},
		messages:{
			username:{ required: "登录名不能为空！", minlength: "登录名不能少于4个字符！", maxlength: "登录名不能多于20个字符！"
				, remote: "登录名已经存在,请选择其他登录名" },
			password:{ required: "密码不能为空！", minlength:"密码不能少于6个字符！" },
			chkpass:{ required: "验证密码不能为空！", equalTo: "密码不一致！" },
			orgname:{ required: "公司名称不能为空！" },
			email:{ required: "电子邮件不能为空！", email: "电子邮件格式不正确！", remote: "电子邮件已经存在" },
			businessname:{ required:"请选择行业！" },
			phone:{ required:"请填写公司电话！" },
			mobile:{ required:"请填写手机号码！" }
		}
	}); 
	return obj;
}
function initInfoChk(){
	obj = $("#myform").validate({
		rules:{
			title:{ required: true },
			expiretime:{ required: true },
			regionname:{ required: true },
			content:{ required: true }
		},
		messages:{
			title:{ required: "招聘信息名称不能为空！" },
			expiretime:{ required: "截止日期不能为空！" },
			regionname:{ required: "请选择城市！" },
			content:{ required: "职位详细描述不能为空！" }
		}
	}); 
	return obj;
}
function initUserEdit(){
	obj = $("#myform").validate({
		rules:{
			orgname:{ required: true },
			email:{ required: true, email:true }
		},
		messages:{
			orgname:{ required: "公司名称不能为空！" },
			email:{ required: "电子邮件不能为空！", email: "电子邮件格式不正确！" }
		}
	}); 
	return obj;
}
function chkUserName(obj){
	var name = $.trim($("#username").val());			
	if(name.length == 0){
		return false;
	}
	$.get(
		'chk.php?username=' + name,
		function(data){					
			if(data != "1"){
				obj.showLabel($('#username')[0], '登录名已经存在,请选择其他登录名');
				return false;
			}
		}
	);
	return true;
}
function setFormMsg(flag, validator){
	switch(flag){
		case -101:
			validator.showLabel($('#username')[0], '登录名不能为空！');
			break;
		case -102:
			validator.showLabel($('#username')[0], '登录名已经存在,请选择其他登录名！');
			break;
		case -103:
			validator.showLabel($('#username')[0], '登录名不能少于4个字符！');
			break;
		case -104:
			validator.showLabel($('#username')[0], '登录名不能多于20个字符！');
			break;			
		case -201:
			validator.showLabel($('#password')[0], '密码不能为空！');
			break;
		case -202:
			validator.showLabel($('#chkpass')[0], '密码不一致！');
			break;
		case -203:
			validator.showLabel($('#password')[0], '密码不能少于6个字符！');
			break;			
		case -301:
			validator.showLabel($('#orgname')[0], '公司名称不能为空！');
			break;
		case -401:
			validator.showLabel($('#email')[0], '电子邮件不能为空！');
			break;
		case -402:
			validator.showLabel($('#email')[0], '电子邮件已经存在！');
			break;
		case -501:
			validator.showLabel($('#businessname')[0], '请选择行业！');
			break;	
		case -701:
			validator.showLabel($('#phone')[0], '请填写公司电话！');
			break;	
		case -801:
			validator.showLabel($('#mobile')[0], '请填写手机号码！');
			break;	
	}
}
function setInfoFormMsg(flag, validator){
	switch(flag){
		case -101:
			validator.showLabel($('#title')[0], '招聘信息名称不能为空！');
			break;			
		case -201:
			validator.showLabel($('#password')[0], '截止日期不能为空！');
			break;		
		case -301:
			validator.showLabel($('#orgname')[0], '职位详细描述不能为空！');
			break;
		case -401:
			validator.showLabel($('#regionname')[0], '请选择城市！');
			break;			
	}
}

function Demo()
{
	var speed=30; //����Խ���ٶ�Խ�� 
	var tab=document.getElementById("demo"); 
	var tab1=document.getElementById("demo1"); 
	var tab2=document.getElementById("demo2");
	tab2.innerHTML=tab1.innerHTML; 
	function Marquee(){ 
		if(tab2.offsetWidth-tab.scrollLeft<=0){
			tab.scrollLeft-=tab1.offsetWidth ;
		}else{ 
			tab.scrollLeft++;
		} 
	} 
	var MyMar=setInterval(Marquee,speed); 
	tab.onmouseover=function() {clearInterval(MyMar)}; 
	tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)}; 
}