﻿// JScript 文件
    function aH(){
	    var body_height = document.getElementsByTagName("body")[0].clientHeight;
	    var html_height = document.getElementsByTagName("html")[0].clientHeight;
	    var a = document.getElementById("alert_filter");
	    a.style.height = (body_height > html_height ? body_height : html_height) + "px"
    }
    function ChangeDialogBGBlock(){
         aH();
         $("#alert_filter").css("display","block");
         
    }
    function ChangeDialogBGNone(){
         
         $("#alert_filter").css("display","none");
         
    }

  function getUserName(){
      var reguseremail=$("#reg_useremail").val(); 
	if (reguseremail=="")
	{
		
		WriteRegInfo("请输入正确的邮箱！","1");
		return false;
	}else{
	          var emailPat=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
              var matchArray=reguseremail.match(emailPat);
              if (matchArray==null){

				WriteRegInfo("请输入正确的邮箱！","1");
				return false;
		}
	}
	
       $.ajax({
          type:"GET",
          url:"/User/checkUserName.aspx?username="+escape(reguseremail)+"&datetime="+(new Date().getTime()),
          dateType:"html",
          success:function(msg){
            
              if(msg=="1"){
                 WriteRegInfo("邮箱已经被注册！","1");
              }
               if(msg=="2"){
                  CloseWriteRegInfo(1);
              }
           }
       })
			 
       
       
       
} 
  function getUserName2(){
      var reguseremail=$("#reg_useremail2").val(); 
	if (reguseremail=="")
	{
		
		WriteRegInfo2("请输入正确的邮箱！","1");
		return false;
	}else{
	          var emailPat=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
              var matchArray=reguseremail.match(emailPat);
              if (matchArray==null){

				WriteRegInfo2("请输入正确的邮箱！","1");
				return false;
		}
	}
	
       $.ajax({
          type:"GET",
          url:"/User/checkUserName.aspx?username="+escape(reguseremail)+"&datetime="+(new Date().getTime()),
          dateType:"html",
          success:function(msg){
            
              if(msg=="1"){
                 WriteRegInfo2("邮箱已经被注册！","1");
              }
               if(msg=="2"){
                  CloseWriteRegInfo2(1);
              }
           }
       })
			 
       
       
       
}
//验证昵称********************************************

	function getNicheng()
	{
	    var regnicheng=$("#reg_nicheng").val();
		if (regnicheng!= "" )
		 {
			if (!(checkInputChar(regnicheng)))
			{
		    	
		    	 WriteRegInfo("用户昵称输入了非法字符！建议使用中文昵称！","4");
				return false;
			}
			if(strLen(regnicheng)<4 || strLen(regnicheng)>60){
			   
			     WriteRegInfo("昵称长度4-16位 字符、不含特殊符、一个汉字占两字符！","4");
				return false;
			}
			if(!(Filter_SQL_key(regnicheng))){
			    WriteRegInfo("用户昵称输入了非法字符！建议使用中文昵称！","4");
				return false;
			}
			
		}
		else
		{
			
				 WriteRegInfo("昵称长度4-16位 字符、不含特殊符、一个汉字占两字符！","4");
				return false;
		}
		
	  $.ajax({
          type:"GET",
          url:"/User/checknicheng.aspx?nicheng="+escape(regnicheng)+"&datetime="+(new Date().getTime()),
          dateType:"html",
          success:function(msg){
            
              if(msg=="1"){
                 WriteRegInfo("此昵称已经被使用！","4");
              }
               if(msg=="2"){
                  CloseWriteRegInfo("4");
              }
           }
       })
        
       
    }
    //验证昵称********************************************

	function getNicheng2()
	{
	    var regnicheng=$("#reg_nicheng2").val();
		if (regnicheng!= "" )
		 {
			if (!(checkInputChar(regnicheng)))
			{
		    	
		    	 WriteRegInfo2("用户昵称输入了非法字符！建议使用中文昵称！","4");
				return false;
			}
			if(strLen(regnicheng)<4 || strLen(regnicheng)>60){
			   
			     WriteRegInfo2("昵称长度4-16位 字符、不含特殊符、一个汉字占两字符！","4");
				return false;
			}
			if(!(Filter_SQL_key(regnicheng))){
			    WriteRegInfo2("用户昵称输入了非法字符！建议使用中文昵称！","4");
				return false;
			}
			
		}
		else
		{
			
				 WriteRegInfo2("昵称长度4-16位 字符、不含特殊符、一个汉字占两字符！","4");
				return false;
		}
		
	  $.ajax({
          type:"GET",
          url:"/User/checknicheng.aspx?nicheng="+escape(regnicheng)+"&datetime="+(new Date().getTime()),
          dateType:"html",
          success:function(msg){
            
              if(msg=="1"){
                 WriteRegInfo2("此昵称已经被使用！","4");
              }
               if(msg=="2"){
                  CloseWriteRegInfo2("4");
              }
           }
       })
        
       
    }
//验证个人信息表单
function checkReg()
{  

	
      var reguseremail=$("#reg_useremail").val(); 
      var regpassword=$("#reg_password").val();
      var regqrpassword=$("#reg_qrpassword").val();
      var regnicheng=$("#reg_nicheng").val();
       if(reguseremail != "" ){
              var emailPat=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
              var matchArray=reguseremail.match(emailPat);
              if (matchArray==null){

				WriteRegInfo("请输入正确的邮箱！","1");
				return false;
			  }else{
				 CloseWriteRegInfo("1");
			  }
		}else{
				
				WriteRegInfo("邮箱地址不允许为空！","1");
				return false;
		}

	       if(regpassword.length < 6 || regpassword.length > 12){
			
				WriteRegInfo("请输入6-12个字符的登录密码！","2");
            	return false;
        	}
        	if (isChinese(regpassword)){
				
				WriteRegInfo("密码不能是中文！","2");
  				return false;
			}

			if (regpassword !=regqrpassword ) {
			
			     WriteRegInfo("您输入的密码不一致，请再次确认密码！","3");
			   
			    return false;
		  }else{
				
				 CloseWriteRegInfo("2");
				  CloseWriteRegInfo("3");
		 }	

         if (regnicheng != "" ) {
			    if (!(checkInputChar(regnicheng))){
				 
				    WriteRegInfo("用户昵称输入了非法字符！","4");
				    return false;
			    }else{
			         if(regnicheng.length < 4 || regnicheng.length > 16){
			
				       WriteRegInfo("昵称长度4-16位 字符、一个汉字占两字符！","4");
            	       return false;
        	          }
			        if(!(Filter_SQL_key(regnicheng))){
			             WriteRegInfo("用户昵称含有非法字符！","4");
				        return false;
			        }else{
				        CloseWriteRegInfo("4");
				    }
    	
			    }
		}else{
				
				WriteRegInfo("用户昵称不允许为空！","4");
				return false;
		}
      
	/*if ($("checkstr").value=="" ) {	
			$("divcheckstr").innerHTML="<span  class='reg_errorh'>请填写验证码，验证码中字母不区分大小写</span>";
		return false;
	}
	else
	{
	    $("divcheckstr").innerHTML="";
	
	}	*/
	  if ($("#reg_xieyi").attr("checked")==false ) {	
			
			WriteRegInfo("请仔细阅读并同意《Nextgame用户注册协议书》","5");
		return false;
	}
	else
	{
	     CloseWriteRegInfo("5");
	
	}	
	

		return true;
}
//验证个人信息表单
function checkReg2()
{  

	
      var reguseremail=$("#reg_useremail2").val(); 
      var regpassword=$("#reg_password2").val();
      var regqrpassword=$("#reg_qrpassword2").val();
      var regnicheng=$("#reg_nicheng2").val();
       if(reguseremail != "" ){
              var emailPat=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
              var matchArray=reguseremail.match(emailPat);
              if (matchArray==null){

				WriteRegInfo2("请输入正确的邮箱！","1");
				return false;
			  }else{
				 CloseWriteRegInfo2("1");
			  }
		}else{
				
				WriteRegInfo2("邮箱地址不允许为空！","1");
				return false;
		}

	       if(regpassword.length < 6 || regpassword.length > 12){
			
				WriteRegInfo2("请输入6-12个字符的登录密码！","2");
            	return false;
        	}
        	if (isChinese(regpassword)){
				
				WriteRegInfo2("密码不能是中文！","2");
  				return false;
			}

			if (regpassword !=regqrpassword ) {
			
			     WriteRegInfo2("您输入的密码不一致，请再次确认密码！","3");
			   
			    return false;
		  }else{
				
				 CloseWriteRegInfo2("2");
				  CloseWriteRegInfo2("3");
		 }	

         if (regnicheng != "" ) {
			    if (!(checkInputChar(regnicheng))){
				 
				    WriteRegInfo2("用户昵称输入了非法字符！","4");
				    return false;
			    }else{
			         if(regnicheng.length < 4 || regnicheng.length > 16){
			
				       WriteRegInfo2("昵称长度4-16位 字符、一个汉字占两字符！","4");
            	       return false;
        	          }
			        if(!(Filter_SQL_key(regnicheng))){
			             WriteRegInfo2("用户昵称含有非法字符！","4");
				        return false;
			        }else{
				        CloseWriteRegInfo2("4");
				    }
    	
			    }
		}else{
				
				WriteRegInfo2("用户昵称不允许为空！","4");
				return false;
		}
      
	/*if ($("checkstr").value=="" ) {	
			$("divcheckstr").innerHTML="<span  class='reg_errorh'>请填写验证码，验证码中字母不区分大小写</span>";
		return false;
	}
	else
	{
	    $("divcheckstr").innerHTML="";
	
	}	*/
	  if ($("#reg_xieyi2").attr("checked")==false ) {	
			
			WriteRegInfo2("请仔细阅读并同意《Nextgame用户注册协议书》","5");
		return false;
	}
	else
	{
	     CloseWriteRegInfo2("5");
	
	}	
	ChangeDialogBGBlock();

		return true;
}
function WriteRegInfo(str,cnum){

            if(cnum=="1"){
			   $("#reg_useremail_img").css("display","");
			}
			else if(cnum=="2"){
			   $("#reg_password_img").css("display","");
			}
			else if(cnum=="3"){
			   $("#reg_qrpassword_img").css("display","");
			}
			else if(cnum=="4"){
			   $("#reg_nicheng_img").css("display","");
			}else{
			   $("#reg_useremail_img").css("display","none");
			   $("#reg_password_img").css("display","none");
			   $("#reg_qrpassword_img").css("display","none");
			   $("#reg_nicheng_img").css("display","none");
			}
			if(cnum=="reg"){
			   
			}else{
			    $("#reg_info_img").css("display","block");
			}
           
			$("#reg_info").html(str);
			
}
function WriteRegInfo2(str,cnum){

            if(cnum=="1"){
			   $("#reg_useremail_img2").css("display","");
			}
			else if(cnum=="2"){
			   $("#reg_password_img2").css("display","");
			}
			else if(cnum=="3"){
			   $("#reg_qrpassword_img2").css("display","");
			}
			else if(cnum=="4"){
			   $("#reg_nicheng_img2").css("display","");
			}else{
			   $("#reg_useremail_img2").css("display","none");
			   $("#reg_password_img2").css("display","none");
			   $("#reg_qrpassword_img2").css("display","none");
			   $("#reg_nicheng_img2").css("display","none");
			}
            $("#reg_info_img2").css("display","block");
			$("#reg_info2").html(str);
			
}
function CloseWriteRegInfo(num){
           $("#reg_info_img").css("display","none");
			$("#reg_info").html("");
           if(num=="1"){
			   $("#reg_useremail_img").css("display","none");
			}
			else if(num=="2"){
			   $("#reg_password_img").css("display","none");
			}
			else if(num=="3"){
			   $("#reg_qrpassword_img").css("display","none");
			}
			else if(num=="4"){
			   $("#reg_nicheng_img").css("display","none");
			}else{
			   $("#reg_useremail_img").css("display","none");
			    $("#reg_password_img").css("display","none");
			     $("#reg_qrpassword_img").css("display","none");
			      $("#reg_nicheng_img").css("display","none");
			}
}
function CloseWriteRegInfo2(num){
           $("#reg_info_img2").css("display","none");
			$("#reg_info2").html("");
           if(num=="1"){
			   $("#reg_useremail_img2").css("display","none");
			}
			else if(num=="2"){
			   $("#reg_password_img2").css("display","none");
			}
			else if(num=="3"){
			   $("#reg_qrpassword_img2").css("display","none");
			}
			else if(num=="4"){
			   $("#reg_nicheng_img2").css("display","none");
			}else{
			   $("#reg_useremail_img2").css("display","none");
			    $("#reg_password_img2").css("display","none");
			     $("#reg_qrpassword_img2").css("display","none");
			      $("#reg_nicheng_img2").css("display","none");
			}
}
function resetReg(){
     CloseWriteRegInfo(5);
      $("#reg_useremail").val("");
      $("#reg_password").val("");
      $("#reg_qrpassword").val("");
      $("#reg_nicheng").val("");
      $("#reg_xieyi").attr("checked",true);
}
function resetReg2(){
     CloseWriteRegInfo2(5);
      $("#reg_useremail2").val("");
      $("#reg_password2").val("");
      $("#reg_qrpassword2").val("");
      $("#reg_nicheng2").val("");
      $("#reg_xieyi2").attr("checked",true);
}
function User_Reg_Action(){
     ChangeDialogBGBlock()
    $("#user_reg_action").css("display","block");
}
function Close_User_Reg_Action(){
    $("#user_reg_action").css("display","none");
    ChangeDialogBGNone();
}
function User_Reg_Action_Login(){
     ChangeDialogBGBlock()
    $("#user_reg_action_ok").css("display","block");
}
function Close_User_Reg_Action_Login(){
   location.reload();
   // $("#user_reg_action_ok").css("display","none");
   // ChangeDialogBGNone();
}
function User_Reg_Actioning(){
   var result=checkReg();
   if(result==true){
        //---------------------------------------------
             
              var reg_useremail = $.trim($("#reg_useremail").val());
              var reg_password = $.trim($("#reg_password").val());
              var reg_qrpassword=$.trim($("#reg_qrpassword").val());
              var reg_nicheng = $.trim($("#reg_nicheng").val());
              $.ajax({
                type:"GET",
                url:"/getuserreg.aspx",
                data:"reg_useremail="+reg_useremail+"&reg_password="+reg_password+"&reg_qrpassword="+reg_qrpassword+"&reg_nicheng="+escape(reg_nicheng)+"&datetime"+(new Date().getTime()),
                dateType:"html",
                error:function(){},
                success:function(msg){
                  if(msg=="1"){
                
                  WriteRegInfo("注册信息不完整！","5");

                  }
                   else if(msg=="2"){
                   
                    WriteRegInfo("对不起，系统繁忙！","5");

                  }
                   else if(msg=="3"){
                  
                 WriteRegInfo("邮箱包含非法字符！","1");

                  }
                   
                  else if(msg=="4"){
                  
                  WriteRegInfo("邮箱地址不能超过30个字符！","1");

                  }
                  else if(msg=="5"){
                   
                   WriteRegInfo("密码长度6～12位字符、字母区分大小写！","2");

                  }
                  else if(msg=="6"){
                   
                 WriteRegInfo("昵称长度4-16位 字符、不含特殊符、一个汉字占两字符！","4");

                  }
                  else if(msg=="7"){
                  
                  WriteRegInfo("邮箱已经被注册！","1");

                  }
                  else if(msg=="8"){
                  
                 WriteRegInfo("此昵称已经被使用！","4");
                  }
                  else if(msg=="9"){
                  
                 WriteRegInfo("邮箱已经被注册！","1");

                  }
                  else if(msg=="10"){
                  
                      WriteRegInfo("密码与确认密码不符！","3");

                  }
                  else{
                  
                    
                     // location.href="http://www.nextgame.cn/game/Login_QLJ.aspx";
                     $("#user_reg_action_ok_name").html(reg_nicheng);
                     User_Reg_Action_Login();
                       
                  }
                }
              });
        //---------------------------------------------
   }
}
function UserRegCheck(){
     ChangeDialogBGBlock();
     $("#checkuserlogin_ok").css("display","block");
     //setTimeout("CloseUserRegCheck()", 2000);
}
function CloseUserRegCheck(){
     ChangeDialogBGNone();
     $("#checkuserlogin_ok").css("display","none");
}


