//index.jsp
function SetPinYinOrProduct(thisobj)
{
	var tempArr = thisobj.className.split("_");
	if( tempArr[2] == "2" )
	{
		document.getElementById("indexChange1").className="pinyinIndex_1_2";
		document.getElementById("indexChange2").className="pinyinIndex_2_2";
		document.getElementById("floatwindow").style.display="none";
		document.getElementById("pinyinIndex").style.display="none";
		thisobj.className = "pinyinIndex_" + tempArr[1] + "_1";
		if( tempArr[1] == "1" )
		document.getElementById("floatwindow").style.display="block";
		else
		document.getElementById("pinyinIndex").style.display="block";
	}
}
function area_pricei(num){
	 if(num==1){
		 eval("pricecontent" + 1 + ".style.display=\"block\";");
		 eval("pricecontent" + 2 + ".style.display=\"none\";");
		 eval("pricecontent" + 3 + ".style.display=\"none\";");
		 eval("pricecontent" + 4 + ".style.display=\"none\";");
		 
		 eval("priceareai" + 1 + ".className=\"pop_5_1_1\";");
		 eval("priceareai" + 2 + ".className=\"pop_5_1_2\";");
		 eval("priceareai" + 3 + ".className=\"pop_5_1_2\";");
		 eval("priceareai" + 4 + ".className=\"pop_5_1_2\";");
		 }
  
       if(num==2){
		 eval("pricecontent" + 1 + ".style.display=\"none\";");
		 eval("pricecontent" + 2 + ".style.display=\"block\";");
		 eval("pricecontent" + 3 + ".style.display=\"none\";");
		 eval("pricecontent" + 4 + ".style.display=\"none\";");
		 
		 eval("priceareai" + 1 + ".className=\"pop_5_1_2\";");
		 eval("priceareai" + 2 + ".className=\"pop_5_1_1\";");
		 eval("priceareai" + 3 + ".className=\"pop_5_1_2\";");
		 eval("priceareai" + 4 + ".className=\"pop_5_1_2\";");
		 }
		 if(num==3){
		 eval("pricecontent" + 1 + ".style.display=\"none\";");
		 eval("pricecontent" + 2 + ".style.display=\"none\";");
		 eval("pricecontent" + 3 + ".style.display=\"block\";");
		 eval("pricecontent" + 4 + ".style.display=\"none\";");
		 
		 eval("priceareai" + 1 + ".className=\"pop_5_1_2\";");
		 eval("priceareai" + 2 + ".className=\"pop_5_1_2\";");
		 eval("priceareai" + 3 + ".className=\"pop_5_1_1\";");
		 eval("priceareai" + 4 + ".className=\"pop_5_1_2\";");
		 }
		 if(num==4){
		 eval("pricecontent" + 1 + ".style.display=\"none\";");
		 eval("pricecontent" + 2 + ".style.display=\"none\";");
		 eval("pricecontent" + 3 + ".style.display=\"none\";");
		 eval("pricecontent" + 4 + ".style.display=\"block\";");
		 
		 eval("priceareai" + 1 + ".className=\"pop_5_1_2\";");
		 eval("priceareai" + 2 + ".className=\"pop_5_1_2\";");
		 eval("priceareai" + 3 + ".className=\"pop_5_1_2\";");
		 eval("priceareai" + 4 + ".className=\"pop_5_1_1\";");
		 }
		 if(num==5){
			 eval("pricecontent" + 5 + ".style.display=\"block\";");
			 eval("pricecontent" + 6 + ".style.display=\"none\";");
			 
			 eval("priceareai" + 5 + ".className=\"pop_5_1_1\";");
			 eval("priceareai" + 6 + ".className=\"pop_5_1_2\";");
			 }
		 if(num==6){
			 eval("pricecontent" + 5 + ".style.display=\"none\";");
			 eval("pricecontent" + 6 + ".style.display=\"block\";");
			 
			 eval("priceareai" + 5 + ".className=\"pop_5_1_2\";");
			 eval("priceareai" + 6 + ".className=\"pop_5_1_1\";");
			 }
		 if(num==7){
			 eval("pricecontent" + 7 + ".style.display=\"block\";");
			 eval("pricecontent" + 8 + ".style.display=\"none\";");
			 
			 eval("priceareai" + 7 + ".className=\"pop_5_1_1\";");
			 eval("priceareai" + 8 + ".className=\"pop_5_1_2\";");
			 }
		 if(num==8){
			 eval("pricecontent" + 7 + ".style.display=\"none\";");
			 eval("pricecontent" + 8 + ".style.display=\"block\";");
			 
			 eval("priceareai" + 7 + ".className=\"pop_5_1_2\";");
			 eval("priceareai" + 8 + ".className=\"pop_5_1_1\";");
			 }
	 }
//密码mima.jsp
function cklog(){
    var name=form1.f_name.value;
    var yanzhengma=form1.yanzhengma.value;
    var cks=document.all("hytype");
    var hytype="";
    for(var i=0;i<cks.length;i++)
    {
       if(cks[i].checked)
	      {
	          hytype=cks[i].value;
		  }
    }
    if(name=="")
     {
         alert("用户名不能为空");
         form1.f_name.focus();
         return false;
     }
     if(yanzhengma=="")
     {
         alert("验证码不能为空");
         form1.yanzhengma.focus();
         return false;
     }else{
   
			//提交到服务器端进行验证，才用AJAX,先或得AJAX引擎
			createXMLHttpRequest();
			//声明要访问的服务器资源
			var str = "/login.do?method=xiugaimima&hytype="+hytype+"&f_name="+name+"&yanzhengma="+yanzhengma;
			//建立一服务器的连接
			XMLHttpReq.open("get", str, true);
			//明确回调函数
			XMLHttpReq.onreadystatechange = checkResult;
			//真正的发送请求
			XMLHttpReq.send(null);
     }
   return true;
   
}

var XMLHttpReq;
	function createXMLHttpRequest() {
		if (window.ActiveXObject) { //判断是不是ActiveXobObject组建
			XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			XMLHttpReq = new XMLHttpRequest();
		}
	}

	function checkResult() {
		//回调函数，处理响应结果的函数
		//先判断当前请求是否是处理完成
		if (XMLHttpReq.readystate == 4) {
			//判断当前的请求是否是成功
			if (XMLHttpReq.status == 200) {
				//成功完成,或得响应结果
				var result =XMLHttpReq.responseText;
				if(result=="1"){
				 alert("用户名不存在，请重新输入");
				}else if(result=="2"){
				  window.location.href='/mimawenti.jsp';
				}else if(result=="3"){
				 alert("验证码有误，请重新输入");
				}
			} else {
				//出现异常
				alert("发生异常");
			}
		}
	}
//login.jsp
 function denglu(){
     if(form1.f_name.value=="")
     {
       
         alert("用户名不能为空");
         form1.f_name.focus();
         return false;
     }
     else if(form1.password.value=="")
     {
         alert("验证码不能为空");
         form1.password.focus();
         return false;
     }else{
 		document.form1.action="/login.do?method=denglu";
		document.form1.target="_blank";
		document.form1.submit(); 
		return true;
	}
 }
 function zhuce(){
        window.location.href="/regKind.jsp";
 }
 
 //reg.jsp

 function Verifyname(str)   //检查字符串是否为26个英文字母，0-9的数字，以及-_
 {
   for (nIndex=0; nIndex<str.length; nIndex++)
   {
     cCheck = str.charAt(nIndex);
     if (!(isnumber(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.' ))
     {
       return false;
     }
   }
   return true;					
 }  

 function cklogreg(){
     var name=form1.f_name.value;
     var pass=form1.f_pass.value;
     var wenti=form1.f_wenti.value;
     var answer=form1.f_answer.value;
     var email=form1.f_email.value;
     var yanzhengma=form1.yanzhengma.value;
     if(form1.f_name.value=="")
      {
          alert("用户名不能为空");
          return false;
      }
      if (!Verifyname(document.form1.f_name.value)) 
	  {
	    alert("对不起，用户名只能使用字母、数字以及 - 和 _ 和. 并且不能使用汉字");
	    return false;
	  }	   
	  
	  if (document.form1.f_name.value<6)
	  {
	    alert("对不起，用户名至少有6位");
	    return false;
	  }

	  if(form1.f_pass.value=="")
      {
          alert("密码不能为空");
          return false;
      }
	  if (!Verifyname(document.form1.f_pass.value)) 
	  {
	    alert("对不起，密码只能使用字母、数字以及 - 和 _ ，并且不能使用汉字");
	    return false;
	  }	   
	  
	  if (document.form1.f_pass.value.length<6)
	  {
	    alert("对不起，密码至少有6位");
	    return false;
	  }
      if(form1.f_upasstoo.value=="")
      {
          alert("重复密码不能为空");
          form1.f_upasstoo.focus();
          return false;
      } if(form1.f_pass.value!=form1.f_upasstoo.value)
      {
          alert("两次密码不一致");
          form1.f_upasstoo.focus();
          return false;
      }if(form1.f_email.value=="")
      {
          alert("邮箱不能为空");
          form1.f_email.focus();
          return false;
      }
      else{
        if((form1.f_email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/))==null){
          alert("邮箱格式不正确");
          form1.f_email.focus();
          return false;
         }
      }
      if(form1.f_wenti.value.length<=0)
      {
          alert("问题不能为空");
          form1.f_wenti.focus();
          return false;
      }
      if(form1.f_answer.value=="")
      {
          alert("回答不能为空");
          form1.f_answer.focus();
          return false;
      }
       if(form1.checkbox.checked==false)
      {
          alert("请选中用户协议");
          return false;
      }
      if(form1.yanzhengma.value=="")
      {
          alert("验证码不能为空");
          form1.yanzhengma.focus();
          return false;
      }else{
    
			//提交到服务器端进行验证，才用AJAX,先或得AJAX引擎
			createXMLHttpRequest();
			//声明要访问的服务器资源
			var str = "/login.do?method=zhuce&f_name="+name+"&f_pass="+pass+"&f_wenti="+wenti+"&f_answer="+answer+"&f_email="+email+"&yanzhengma="+yanzhengma;
			//建立一服务器的连接
			XMLHttpReq.open("get", str, true);
			//明确回调函数
			XMLHttpReq.onreadystatechange = checkResultreg;
			//真正的发送请求
			XMLHttpReq.send(null);
      }
    return true;
 }
	function checkResultreg() {
		//回调函数，处理响应结果的函数
		//先判断当前请求是否是处理完成
		if (XMLHttpReq.readystate == 4) {
			//判断当前的请求是否是成功
			if (XMLHttpReq.status == 200) {
				//成功完成,或得响应结果
				var result =XMLHttpReq.responseText;
				if(result=="1"){
				 alert("用户名存在");
				}else if(result=="2"){
				 alert("注册失败");
				}else if(result=="3"){
				 alert("验证码有误，请重新输入");
				}else{
				   document.getElementById("zhuceok").style.display="block";
				   document.getElementById("zhuceok").innerHTML="<font color='red'>恭喜你，注册成功!您的会员卡号是："+result+"</font> <a href='/login.jsp'>登录</a>后可进入个人帐户";
				}
				
			} else {
				//出现异常
				alert("发生异常");
			}
		}
	}
	//检测用户名是否合法
	function checkUsername(){
	  var username=document.getElementById("f_name").value;
	  if (username=='') 
	  {
	    window.alert ("请输入您的用户名")
	    mobj = eval("document.getElementById('f_name')");
	    mobj.focus();
	    mobj.select();
	    return false;
	  }

	  if (!Verifyname(username)) 
	  {
	    alert("用户名只能使用字母、数字以及 - 和 _ 和. 并且不能使用汉字");
	    mobj = eval("document.getElementById('f_name')");
	    mobj.focus();
	    mobj.select();
	    return false;
	  }	
	
	   
	  if (username.length<6) 
	  {
	    window.alert ("出于安全的考虑，您的用户名至少6位")
	    mobj = eval("document.getElementById('f_name')");
	    mobj.focus();
	    mobj.select();
	    return false;
	  }

            //检测是否合法
            
            //提交到服务器端进行验证，才用AJAX,先或得AJAX引擎
			createXMLHttpRequest();
			//声明要访问的服务器资源
			var str = "/login.do?method=checkUsername&username="+username;
			//建立一服务器的连接
			XMLHttpReq.open("get", str, true);
			//明确回调函数
			XMLHttpReq.onreadystatechange = checkResult1;
			//真正的发送请求
			XMLHttpReq.send(null);
}

function checkResult1() {
		//回调函数，处理响应结果的函数
		//先判断当前请求是否是处理完成
		if (XMLHttpReq.readystate == 4) {
			//判断当前的请求是否是成功
			if (XMLHttpReq.status == 200) {
				//成功完成,或得响应结果
				var result =XMLHttpReq.responseText;
				if(result==""){
				  alert("用户名可用")
				  }else{
				  alert(result);
				  }
			} else {
				//出现异常
				alert("发生异常");
			}
		}
	}
	
//reg1.jsp
function oncheck()
{
        if(form1.f_username.value=="")
        {
            alert("用户名不能为空");
            return false;
        }
        if (!Verifyname(document.form1.f_username.value)) 
	  {
	    alert("对不起，用户名只能使用字母、数字以及 - 和 _ 和. 并且不能使用汉字");
	    return false;
	  }	   
	  
	  if (document.form1.f_username.value<6)
	  {
	    alert("对不起，用户名至少有6位");
	    return false;
	  }
        if(form1.f_userpass.value=="")
        {
            alert("密码不能为空");
            return false;
        }
	
	  if (!Verifyname(document.form1.f_userpass.value)) 
	  {
	    alert("对不起，密码只能使用字母、数字以及 - 和 _ ，并且不能使用汉字");
	    return false;
	  }	   
	  
	  if (document.form1.f_userpass.value.length<6)
	  {
	    alert("对不起，密码至少有6位");
	    return false;
	  }
        if(form1.f_repass.value=="")
        {
            alert("重复密码不能为空");
            return false;
        } if(form1.f_repass.value!=form1.f_userpass.value)
        {
            alert("两次密码不一致");
            return false;
        }if(form1.f_answer.value=="")
        {
            alert("回答不能为空");
            return false;
        }if(form1.f_name.value=="")
        {
            alert("真实姓名不能为空");
            return false;
        }if(form1.f_userage.value=="")
        {
            alert("年龄不能为空");
            return false;
        }if(form1.f_email.value=="")
        {
            alert("邮箱不能为空");
            return false;
        }else{
          if((form1.f_email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/))==null){
            alert("邮箱格式不正确");
            return false;
           }
        }if(form1.f_QQ.value=="")
        {
            alert("QQ号码不能为空");
            return false;
        }
         else{
          if((form1.f_QQ.value.match(/[1-9][0-9]{4,}/))==null){
            alert("QQ格式不正确");
            return false;
           }
        }
        
        if(form1.f_phone.value=="")
        {
            alert("手机号码不能为空");
            return false;
        }else{
          if((form1.f_phone.value.match(/^1[3,5]{1}[0-9]{1}[0-9]{8}$/))==null){
            alert("手机号码格式不正确");
            return false;
           }
        }
        if(form1.zhiyeid.value==""){
          alert("请选择职业");
          return false;
        }
        if(form1.selA.value.length<=0)
        {
            alert("省不能为空");
           return false;
        }
        if(form1.selB.value.length<=0)
        {
            alert("市不能为空");
           return false;
        }

        if(form1.f_zhengjian.value=="")
        {
            alert("证件号码不能为空");
            return false;
        }
         if(form1.checkbox.checked==false)
        {
            alert("请选中用户协议");
            return false;
        }
        return true;
}

//检测用户名是否合法
function checksecname(){
  var username=document.getElementById("f_username").value;
  if (username=='') 
  {
    window.alert ("请输入您的用户名")
    mobj = eval("document.getElementById('f_username')");
    mobj.focus();
    mobj.select();
    return false;
  }

  if (!Verifyname(username)) 
  {
    alert("用户名只能使用字母、数字以及 - 和 _ 和. 并且不能使用汉字");
    mobj = eval("document.getElementById('f_username')");
    mobj.focus();
    mobj.select();
    return false;
  }	

   
  if (username.length<6) 
  {
    window.alert ("出于安全的考虑，您的用户名至少6位")
    mobj = eval("document.getElementById('f_name')");
    mobj.focus();
    mobj.select();
    return false;
  }

        //检测是否合法
        
        //提交到服务器端进行验证，才用AJAX,先或得AJAX引擎
		createXMLHttpRequest();
		//声明要访问的服务器资源
		var str = "/secretary.do?method=checkUsername&username="+username;
		//建立一服务器的连接
		XMLHttpReq.open("get", str, true);
		//明确回调函数
		XMLHttpReq.onreadystatechange = checkResultsec;
		//真正的发送请求
		XMLHttpReq.send(null);
}

function checkResultsec() {
	//回调函数，处理响应结果的函数
	//先判断当前请求是否是处理完成
	if (XMLHttpReq.readystate == 4) {
		//判断当前的请求是否是成功
		if (XMLHttpReq.status == 200) {
			//成功完成,或得响应结果
			var result =XMLHttpReq.responseText;
			if(result==""){
			  alert("用户名可用");
			 
			  }else{
			   // document.getElementById("zhuceok").style.display="block";
			   // document.getElementById("zhuceok").innerHTML="<font color='red'>恭喜你，注册成功!您的会员卡号是：<strong>"+result+"</strong></font> <a href='/login.jsp'>登录</a>后可进入个人帐户";
			   alert("用户名存在");
			  }
		} else {
			//出现异常
			alert("发生异常");
		}
	}
}
//xiugaimima.jsp
function cklogxiugai(){
    if(form1.f_pass.value=="")
      {
          alert("新密码不能为空");
          return false;
      }
	  if (!Verifyname(document.form1.f_pass.value)) 
	  {
	    alert("对不起，密码只能使用字母、数字以及 - 和 _ ，并且不能使用汉字");
	    return false;
	  }	   
	  
	  if (document.form1.f_pass.value.length<6)
	  {
	    alert("对不起，密码至少有6位");
	    return false;
	  }
      if(form1.f_upasstoo.value=="")
      {
          alert("确认密码不能为空");
          form1.f_upasstoo.focus();
          return false;
      } if(form1.f_pass.value!=form1.f_upasstoo.value)
      {
          alert("两次密码不一致");
          form1.f_upasstoo.focus();
          return false;
      }
      return true;
     
}

