//关键字提示
$(document).ready(
        function (){
           keyfous("keyword1","服装","action1","truearea",'searchform1');
        }
 );
//关键字提示

function calculate_byte( sTargetStr ) {//求字符串长度
         var sTmpStr, sTmpChar;
         var nOriginLen = 0;
         var nStrLength = 0;
         
         sTmpStr = new String(sTargetStr);
         nOriginLen = sTmpStr.length;

         for ( var i=0 ; i < nOriginLen ; i++ ) {
                 sTmpChar = sTmpStr.charAt(i);

                 if (escape(sTmpChar).length > 4) {
                         nStrLength += 2;
                 } else if (sTmpChar!='\r') {
                         nStrLength ++;
                 }
         }
        
         return nStrLength; 
        
}
function cleartxt(id){	//清除输入框内容
		document.getElementById(id).value="";
		document.getElementById(id).style.color="#FF0000";	
}

function checkForm(act){
	if(document.catform.EcardNO.value==""){
	alert ("请输入卡号！");
	document.catform.EcardNO.focus();
	return false;
	}
	document.getElementById(act).disabled = true;
	return true;
}

function show_div(name1,name2,name3,act1,act2,act3){	
		if(act1 !=''){			
			document.getElementById(name1).style.display = act1;						
		}
		if(act2 !=''){			
			document.getElementById(name2).style.display = act2;						
		}
		if(act3 !=''){			
			document.getElementById(name3).style.display = act3;						
		}
		
}
//js 设置 cookie
function jscookie(value){
	var expiration = new Date((new Date()).getTime() + 60 * 60000);	
	document.cookie = "act=" + value + "; expires ="+ expiration.toGMTString() + "; path=" + "/";
	document.location = "index.shtml";
}

function show_account(num,size){
	for(var i=1;i<=size;i++){
		if(i==num){
			document.getElementById("fbox_middle"+i).style.display="block";							
			document.getElementById("fbox_"+i).className = "s_td2_on";
			var expiration = new Date((new Date()).getTime() + 60 * 60000);	
			document.cookie = "display=" + i + "; expires ="+ expiration.toGMTString() + "; path=" + "/";
		}else{
			document.getElementById("fbox_middle"+i).style.display="none";			
			document.getElementById("fbox_"+i).className = "s_td2_off";				
		}		
	}

}

function checkNull(){	
	if(document.catform.CustomID.value==""){
	alert ("请输入帐号！");
	document.catform.CustomID.focus();
	return false;
	}
	if(document.catform.Password.value==""){
	alert ("请输入密码！");
	document.catform.Password.focus();
	return false;
	}
	if(document.catform.Password.value != document.catform.Password2.value){
	alert ("密码确认与密码不一致！");
	document.catform.Password2.focus();
	return false;
	}
	if(document.catform.cellphone.value==""){
	alert ("请输入短信接受号码！");
	document.catform.cellphone.focus();
	return false;
	}	
	if(document.catform.uname.value==""){
	alert ("请输入真实姓名！");
	document.catform.uname.focus();
	return false;
	}	
	return true;
}

function CheckInfo(){
	if(document.catform2.TCustomID.value==""){
	alert ("请输入帐号！");
	document.catform2.TCustomID.focus();
	return false;
	}
	if(document.catform2.TPassword.value==""){
	alert ("请输入密码！");
	document.catform2.TPassword.focus();
	return false;
	}
	if(document.catform2.Tcellphone.value==""){
	alert ("请输入短信接受号码！");
	document.catform2.Tcellphone.focus();
	return false;
	}	
	if(document.catform2.Tuname.value==""){
	alert ("请输入真实姓名！");
	document.catform2.Tuname.focus();
	return false;
	}	
	return true;
}

function CheckReg(){
	if(document.catform.CustomID.value==""){
	alert ("请输入帐号！");
	document.catform.CustomID.focus();
	return false;
	}
	if(document.catform.Password.value==""){
	alert ("请输入密码！");
	document.catform.Password.focus();
	return false;
	}
	if(document.catform.Password.value != document.catform.Password2.value){
	alert ("密码确认与密码不一致！");
	document.catform.Password2.focus();
	return false;
	}
	return true;
}

function CheckName(){
	if(document.catform.cellphone.value==""){
	alert ("请输入短信接受号码！");
	document.catform.cellphone.focus();
	return false;
	}
	if(document.catform.uname.value==""){
	alert ("请输入真实姓名！");
	document.catform.uname.focus();
	return false;
	}
	return true;
}

function CheckPwd(){
	if(document.catform.OldPassword.value==""){
	alert ("请输入旧密码！");
	document.catform.OldPassword.focus();
	return false;
	}
	if(document.catform.NewPassword.value==""){
	alert ("请输入新密码！");
	document.catform.NewPassword.focus();
	return false;
	}
	if(document.catform.NewPassword.value != document.catform.Password2.value){
	alert ("确认密码与新密码不一致！");
	document.catform.Password2.focus();
	return false;
	}
	return true;
}
function isNumber(val)
{
  var reg = /^-?\d+$/;
  return reg.test(val);
}
function TCheckPwd(){
	if(document.catform.OldPassword.value==""){
	alert ("请输入旧密码！");
	document.catform.OldPassword.focus();
	return false;
	}
	if(document.catform.NewPassword.value==""){
	alert ("请输入新密码！");
	document.catform.NewPassword.focus();
	return false;
	}
	if(document.catform.NewPassword.value != document.catform.Password2.value){
	alert ("确认密码与新密码不一致！");
	document.catform.Password2.focus();
	return false;
	}
	if(!isNumber(document.catform.NewPassword.value) || !isNumber(document.catform.Password2.value)){
		alert ("密码只能是数字！");
		document.catform.NewPassword.value = '';
		document.catform.Password2.value = '';
		document.catform.NewPassword.focus();
		return false;
	}
	return true;
}

function   textCounter(field,   countfield,   maxlimit) 
  {   
  <!--   
  	var   counter   =   0;   
  	var   i;   
  	var   chckcode;   
  	chckcode=field.value.length;   
  	chckcode=chckcode-1;    
  	for   (i   =   0;   i<   field.value.length;   i++)   
    {   
        if   (field.value.charCodeAt(i)   >   127   ||   field.value.charCodeAt(i)   ==   94)   
        {   
         	counter++;   
         	if   (counter>maxlimit)   break;   
        }   
        else   
		{   
            counter++;   
            if   (counter>maxlimit)   break;   
        }   
    }   
    
  	if   (counter   >   maxlimit)   
  	field.value   =   field.value.substring(0,i);   
  	else   
  	countfield.value   =   maxlimit   -   counter;   
  }   
    
  function   isInBag(s,bag){   
      var   i;   
      for   (i   =   0;   i   <   s.length;   i++){   
          var   c   =   s.charAt(i);   
          if   (bag.indexOf(c)   ==   -1){   
              return   false;   
          }   
      }   
      return   true;   
  }  

/*AJAX开始*/
try {
  xmlHttp = new XMLHttpRequest();
} catch (trymicrosoft) {
  try {
    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (othermicrosoft) {
    try {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (failed) {
      xmlHttp = false;
    }
  }
}

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

function Checkuser() //检查帐号是否存在
{
	var CustomID=document.getElementById("CustomID").value;	
	var queryString ="action=CheckExit"+"&CustomID=" + CustomID;
	var url = "/webconfig/regist_deal.php?" + queryString;	
	xmlHttp.open("POST", url, true);
  	xmlHttp.onreadystatechange = EupdatePage;
  	xmlHttp.send(null);
	return true;
}
function EupdatePage() 
{
  	if (xmlHttp.readyState == 4) 
	{
    	var response = xmlHttp.responseText;
		CheckExit.innerHTML = "";
    	CheckExit.innerHTML = response;
  	}
	else
	{
		CheckExit.innerHTML = "请稍后。。。";
  	}
}

function TCheckuser() //检查帐号正确性
{
	var CustomID=document.getElementById("TCustomID").value;
	var Password=document.getElementById("TPassword").value;	
	var queryString ="action=Checkuser"+"&CustomID=" + CustomID +"&Password=" + Password;
	var url = "/webconfig/regist_deal.php?" + queryString;	
	xmlHttp.open("POST", url, true);
  	xmlHttp.onreadystatechange = updatePage1;
  	xmlHttp.send(null);
	return true;
}
function updatePage1() 
{
  	if (xmlHttp.readyState == 4) 
	{
    	var response = xmlHttp.responseText;
		TCheckuserT.innerHTML = "";
    	TCheckuserT.innerHTML = response;
  	}
	else
	{
		TCheckuserT.innerHTML = "请稍后。。。";
  	}
}

function Tsarea() //选择地区
{	
	var province=document.getElementById("Tselectprovince").value;	
	var queryString ="action=Tselectprovince"+"&preareaid=" + province;
	var url = "/webconfig/regist_deal.php?" + queryString;	
	xmlHttp.open("POST", url, true);
  	xmlHttp.onreadystatechange = TupdatePage2;
  	xmlHttp.send(null);
	return true;
}
function TupdatePage2() 
{
  	if (xmlHttp.readyState == 4) 
	{
    	var response = xmlHttp.responseText;
		Tselarea.innerHTML = "";
    	Tselarea.innerHTML = response;
  	}
	else
	{
		Tselarea.innerHTML = "请稍后。。。";
  	}
}

function sarea() //选择地区
{	
	var province=document.getElementById("selectprovince").value;	
	var queryString ="action=selectprovince"+"&preareaid=" + province;
	var url = "/webconfig/regist_deal.php?" + queryString;		
	xmlHttp.open("POST", url, true);
  	xmlHttp.onreadystatechange = updatePage2;
  	xmlHttp.send(null);
	return true;
}
function updatePage2() 
{
  	if (xmlHttp.readyState == 4) 
	{
    	var response = xmlHttp.responseText;
		selarea.innerHTML = "";
    	selarea.innerHTML = response;
  	}
	else
	{
		selarea.innerHTML = "请稍后。。。";
  	}
}

function TCheckPhone() //检查手机号是否使用
{	
	var cellphone=document.getElementById("Tcellphone").value;	
	var CustomID=document.getElementById("TCustomID").value;
	var queryString ="action=Tcheckphone"+"&cellphone=" + cellphone + "&CustomID=" + CustomID;
	var url = "/webconfig/regist_deal.php?" + queryString;		
	xmlHttp.open("POST", url, true);
  	xmlHttp.onreadystatechange = TupdatePhone;
  	xmlHttp.send(null);
	return true;
}
function TupdatePhone() 
{
  	if (xmlHttp.readyState == 4) 
	{
    	var response = xmlHttp.responseText;
		Tphonespan.innerHTML = "";
    	Tphonespan.innerHTML = response;
  	}
	else
	{
		Tphonespan.innerHTML = "请稍后。。。";
  	}
}

function CheckPhone() //检查手机号是否使用
{	
	var cellphone=document.getElementById("cellphone").value;	
	var queryString ="action=Tcheckphone"+"&cellphone=" + cellphone;
	var url = "/webconfig/regist_deal.php?" + queryString;		
	xmlHttp.open("POST", url, true);
  	xmlHttp.onreadystatechange = updatePhone;
  	xmlHttp.send(null);
	return true;
}
function updatePhone() 
{
  	if (xmlHttp.readyState == 4) 
	{
    	var response = xmlHttp.responseText;
		phonespan.innerHTML = "";
    	phonespan.innerHTML = response;
  	}
	else
	{
		phonespan.innerHTML = "请稍后。。。";
  	}
}

function changeclass() //应聘职位类别
{	
	var preclassid=document.getElementById("selectclass").value;	
	var queryString ="action=changeclass"+"&preclassid=" + preclassid;
	var url = "/webconfig/regist_deal.php?" + queryString;		
	xmlHttp.open("POST", url, true);
  	xmlHttp.onreadystatechange = updateclass;
  	xmlHttp.send(null);
	return true;
}
function updateclass() 
{
  	if (xmlHttp.readyState == 4) 
	{
    	var response = xmlHttp.responseText;
		bigclassinfo.innerHTML = "";
    	bigclassinfo.innerHTML = response;
  	}
	else
	{
		bigclassinfo.innerHTML = "请稍后。。。";
  	}
}

/*AJAX结束*/
function checkNO(id,act){
	var length;
	if(/^\d+(\.)?(\d+)?$/.test(document.getElementById(id).value)==false){	 
	  document.getElementById(id).value=document.getElementById(id).value.substr(0,document.getElementById(id).value.length-1)
	}
	length = calculate_byte(document.getElementById(id).value);
	if(length==16){		
		document.getElementById(act).disabled = false;
	}else{
		document.getElementById(act).disabled = true;
	}
	
}

/*2009-07-25*/
function CharMode(iN){
		if (iN>=65 && iN <=90) //大写字母
		return 2;
		if (iN>=97 && iN <=122) //小写
		return 4;
		else
		return 1; //数字
}

//计算出当前密码当中一共有多少种模式
function bitTotal(num){
		modes=0;
		for (i=0;i<3;i++){
				if (num & 1) modes++;
				num>>>=1;
		}
		return modes;
	}
//checkStrong函数 返回密码的强度级别
function checkStrong(sPW){
		Modes=0;
		for (i=0;i<sPW.length;i++){
				//测试每一个字符的类别并统计一共有多少种模式.
				Modes|=CharMode(sPW.charCodeAt(i));
		}
		var btotal = bitTotal(Modes);
		if (sPW.length >= 10) btotal++;
		switch(btotal) {
				case 1:
						return "<table width='130' class='pswstrong'><tr><td bgcolor='#FE707E'><strong>弱</strong></td><td><span style='color:#666;'>中</span></td><td><span style='color:#666;'>强</span></td></tr></table>";
						break;
				case 2:
						return "<table width='130' class='pswstrong'><tr><td bgcolor='#FCFA93'><span style='color:#666;'>弱</span></td><td bgcolor='#FCFA93'><strong>中</strong></td><td><span style='color:#666;'>强</span></td></tr></table>";
						break;
				case 3:
						return "<table width='130' class='pswstrong'><tr><td bgcolor='#BDFEA6'><span style='color:#666;'>弱</span></td><td bgcolor='#BDFEA6'><span style='color:#666;'>中</span></td><td bgcolor='#BDFEA6'><strong>强</strong></td></tr></table>";
						break;
				default:
						return "<font color='#33CC00'>强</font>";
		}
}
function ShowStrong(obj,oMsg,status){
		var obj = document.getElementById(obj);
		if(status==1){
			obj.innerHTML = oMsg
		}else{
				obj.innerHTML = ""
		}
}

function tx_chk(obj)
{
	var name, key, val = obj.value, oShow=oo("chk_"+obj.name);
	name = obj.alt.slice(0,obj.alt.indexOf(":"));
	key = "/"+obj.alt.slice(obj.alt.indexOf(":")+1)+"/";
	oo("chk_"+obj.name).style.display = "none";
	
	if(key.indexOf("/无内容/")>-1&&val==""){
		name = (name=="Password")?"密码":name;
		oShow.innerHTML="请输入"+name
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/4-16/")>-1&&(strLen(val)<4||strLen(val)>16)){
		oShow.innerHTML="长度必须4-16位"
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/4-32/")>-1&&(strLen(val)<4||strLen(val)>32)){
		oShow.innerHTML="长度必须4-32位"
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/6-16/")>-1&&(strLen(val)<6||strLen(val)>16)&&strLen(val)!=0){
		oShow.innerHTML="长度必须6-16位"
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/8-16/")>-1&&(strLen(val)<8||strLen(val)>16)){
		oShow.innerHTML="长度必须8-16位"
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/怪字符/")>-1&&(/>|<|,|\[|\]|\{|\}|\?|\/|\+|=|\||\'|\\|\"|:|;|\~|\!|\@|\#|\*|\$|\%|\^|\&|\(|\)|`/i).test(val)){
		oShow.innerHTML=" 请勿使用特殊字符"
		oShow.style.display=""
		return false
	}	
	if(key.indexOf("/怪字符pwd/")>-1&&(/>|<|\+|,|\[|\]|\{|\}|\/|=|\||\'|\\|\"|:|;|\~|\!|\@|\#|\*|\$|\%|\^|\&|\(|\)|`/i).test(val)){
		oShow.innerHTML=" 请勿使用特殊字符"
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/有空格/")>-1&&val.indexOf(" ")>-1){
		oShow.innerHTML=" 不能包含空格符"
		oShow.style.display=""
		return false
	}
	if( key.indexOf("/首尾不能是空格/")>-1&&val!="")
	{
		var pat_s = /^(\s)/;
		var pat_e = /(\s)$/;

		if ( pat_s.test(val) || pat_e.test( val))
		{
			oShow.innerHTML="首尾不能是空格"
			oShow.style.display=""
			return false
		}
	}
	if(key.indexOf("/全数字/")>-1&&val!=""){
		if ( /^[0-9]+$/.test(val)){
			oShow.innerHTML="不可以全是数字"
			oShow.style.display=""
			return false}
	}
	if(key.indexOf("/有大写/")>-1&&/[A-Z]/.test(val)){
		oShow.innerHTML="不能有大写字母"
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/邮箱域/")>-1 && val != "" && !(/([0-9a-z]+(([0-9a-z]*)|([0-9a-z-]*[0-9a-z]))+\.)+[a-z]{2,4}$/i).test(val)){
		oShow.innerHTML=" 邮箱域有错误";
		oShow.style.display="";
		return false;
	}		
	if(key.indexOf("/英文数字/")>-1&&!/^[a-zA-Z0-9_]*$/.test(val)){
		oShow.innerHTML="只能为英文和数字"
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/有全角/")>-1&&/[ａ-ｚＡ-Ｚ０-９！＠＃￥％＾＆＊（）＿＋｛｝［］｜：＂＇；．，／？＜＞｀～　]/.test(val))
	{
		oShow.innerHTML=" 不能有全角字符"
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/有汉字/")>-1&&escape(val).indexOf("%u")>-1){
		oShow.innerHTML=" 不能有汉字"
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/下划线/")>-1&&val.slice(val.length-1)=="_"){
		oShow.innerHTML="下划线不能在最后"
		oShow.style.display=""
		return false
	}
	if(key.indexOf("/确认密码/")>-1){
		if(obj.form[name].value!=val){
			oShow.innerHTML="确认密码不一致"
			oShow.style.display=""
			return false
		}
	}
	if(key.indexOf("/确认证件号码/")>-1){
		if(obj.form[name].value!=val){
			oShow.innerHTML="确认证件号码不一致"
			oShow.style.display=""
			return false
		}
	}
	if(key.indexOf("/必选/")>-1){
		var ol=obj.form[obj.name],isSel=false
		for(var i=0;i<ol.length;i++){
			if(ol[i].checked)
				isSel=true
		}
		if(!isSel){
			oShow.innerHTML=name+"必须选择"
			oShow.style.display=""
			return false
		}
	}
	if(key.indexOf("/条款/")>-1){
		var ol=obj.form[obj.name],isSel=false
		if(ol.checked){
			isSel=true
		}
		if(!isSel){
			oShow.innerHTML=name+"必须选择"
			oShow.style.display=""
			return false
		}
	}
	if ( name=="password" || name=="密码"){
		ShowStrong('pswstrong',checkStrong(val),1);
	}
	return true
}

function strLen(key){
	var l=escape(key),len
	len=l.length-(l.length-l.replace(/\%u/g,"u").length)*4
	l=l.replace(/\%u/g,"uu")
	len=len-(l.length-l.replace(/\%/g,"").length)*2
	return len
}
