﻿var userEmailString,userEmailState;
var userNameString,userNameState;
var userPassString,userPassState;
var userpassTwoString,userpassTwoState;
var usergetRandom,usergetRandomstate;
var arruser=new Array([3]);
$(document).ready(function(){


	$("#reginfo #tijiao button").eq(0).click(function(){
					
					if(userEmailState!="0")
					{ $("#userEmail").next().html("<img src=\"../images/user/exclamation.gif\" />请重新填写邮箱"); }
					else if(userNameState!="0")
					{ $("#userName").next().html("<img src=\"../images/user/exclamation.gif\" />请重新填写用户名");} 
					else if(userPassState!="0")
					{ $("#userpass").next().html("<img src=\"../images/user/exclamation.gif\" />请重新填写密码");} 
					else if(userpassTwoState!="0")
					{ $("#userpassTwo").next().html("<img src=\"../images/user/exclamation.gif\" />请重新填写密码");} 
					else if(usergetRandomstate!="0")
					{$("#userNub").parents("li").find("span").html("<img src=\"../images/user/exclamation.gif\" />请重新填写验证码");} 
					else
					{
					arruser[0]=userEmailString;
					arruser[1]=userNameString;
					arruser[2]=userPassString;
					var va=getuserReturn();
					if(va=="1")
					{alert("恭喜您，注册成功！");form1.reset();event.returnValue=false;
					userEmailString="";userPassString="";userNameString="";
					userpassTwoString="";usergetRandom="";
					userEmailState="-2";userNameState="-2";userPassState="-2";
                    userpassTwoState="-2";usergetRandomstate="-2";
                    //usergetRandom=getuserRandoM();				
                   // $("#userNub").next().html(usergetRandom);	
                   window.location.href="/index.html";
                  // Response.Redirect("East_User_Reg_ok.aspx");
					}
					else{alert("操作失败");}
					}
					
					
					});
					
//$("#reginfo #tijiao button").eq(1).click(function(){
//form1.reset();event.returnValue=false;
//userEmailString="";userEmailState="";userNameString="";
//userpassTwoString="";usergetRandom="";
//userEmailState="-2";userNameState="-2";userPassState="-2";
//userpassTwoState="-2";usergetRandomstate="-2";
//});
				
usergetRandom=getuserRandoM();				
$("#userNub").next().html(usergetRandom);	

			
					
$("#userEmail").change(function(){

	 userEmailString = 	$("#userEmail").attr("value");
	 var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
	 
	 if(userEmailString=="")
	 {$("#userEmail").next().html("<img src=\"../images/user/spinner.gif\" />");
	  setTimeout(function(){
	  $("#userEmail").next().html("<img src=\"../images/user/exclamation.gif\" />邮箱为必填项");
	  },1000);
	  userEmailState="-2";
	  }
	 else if(!pattern.test(userEmailString))
	 {$("#userEmail").next().html("<img src=\"../images/user/spinner.gif\" />");
	  setTimeout(function(){
	  $("#userEmail").next().html("<img src=\"../images/user/exclamation.gif\" />邮箱格式错误");
	  },1000);
	  userEmailState="-2";
	  }
	  else
	  {   userEmailState=getuserEmail();
	      if(userEmailState=="-1")
	        {$("#userEmail").next().html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userEmail").next().html("<img src=\"../images/user/exclamation.gif\" />邮箱中请使用英文或数字");
	                              },1000);
	        }
	      else if(userEmailState=="0")
	        {$("#userEmail").next().html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userEmail").next().html("<img src=\"../images/user/drop-yes.gif\" />恭喜，邮箱可用");
	                              },1000);
	        }
	       else if(userEmailState=="1")
	        {$("#userEmail").next().html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userEmail").next().html("<img src=\"../images/user/exclamation.gif\" />抱歉，邮箱已被占用");
	                              },1000);
	        }
	  
	  }
	  
	  });
	  
	  
$("#userName").change(function(){

	 userNameString = 	$("#userName").attr("value");
	 
	 if(userNameString=="")
	 {$("#userName").next().html("<img src=\"../images/user/spinner.gif\" />");
	  setTimeout(function(){
	  $("#userName").next().html("<img src=\"../images/user/exclamation.gif\" />用户名为必填项");
	  },1000);
	  userNameState="-2";
	  }
	  else
	  {   userNameState=getuserAccount();
	      if(userNameState=="-1")
	        {$("#userName").next().html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userName").next().html("<img src=\"../images/user/exclamation.gif\" />用户名中请使用英文或数字");
	                              },1000);
	        }
	      else if(userNameState=="0")
	        {$("#userName").next().html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userName").next().html("<img src=\"../images/user/drop-yes.gif\" />恭喜，用户名可用");
	                              },1000);
	        }
	       else if(userNameState=="1")
	        {$("#userName").next().html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userName").next().html("<img src=\"../images/user/exclamation.gif\" />抱歉，用户名已被占用");
	                              },1000);
	        }
	  
	  }
	  
	  });
	 
	 
$("#userpass").change(function(){

	 userPassString = 	$("#userpass").attr("value");
	 
	 if(userPassString=="")
	 {$("#userpass").next().html("<img src=\"../images/user/spinner.gif\" />");
	  setTimeout(function(){
	  $("#userpass").next().html("<img src=\"../images/user/exclamation.gif\" />密码为必填项");
	  },1000);
	  userPassState="-2";
	  }
	  else if($("#userpassTwo").attr("value")!="")
	  {
	  userpassTwoString="";
	  userpassTwoState="-2";
	  $("#userpassTwo").next().html("<img src=\"../images/user/spinner.gif\" />");
	  setTimeout(function(){
	  $("#userpassTwo").attr("value","");
	  $("#userpassTwo").next().html("<img src=\"../images/user/icon-info.gif\" />");
	  },1000);
	  }
	  else
	  {   userPassState=getuserPass();
	      if(userPassState=="-1")
	        {$("#userpass").next().html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userpass").next().html("<img src=\"../images/user/exclamation.gif\" />密码中请使用英文或数字");
	                              },1000);
	        }
	      else if(userPassState=="0")
	        {$("#userpass").next().html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userpass").next().html("<img src=\"../images/user/drop-yes.gif\" />填写正确");
	                              },1000);
	        }
	  }
	  
	  });
	  
	  
	  
$("#userpassTwo").change(function(){

	 userpassTwoString = 	$("#userpassTwo").attr("value");
	 
	 if(userpassTwoString=="")
	 {$("#userpassTwo").next().html("<img src=\"../images/user/spinner.gif\" />");
	  setTimeout(function(){
	  $("#userpassTwo").next().html("<img src=\"../images/user/exclamation.gif\" />请输入上面的密码");
	  },1000);
	   userpassTwoState="-2";
	  }
	  else
	  {   
	      if(userpassTwoString!=userPassString)
	        {$("#userpassTwo").next().html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userpassTwo").next().html("<img src=\"../images/user/exclamation.gif\" />两次密码不一样，请重试");
	                              },1000);
	      userpassTwoState="-2";
	        }
	      else 
	        {$("#userpassTwo").next().html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userpassTwo").next().html("<img src=\"../images/user/drop-yes.gif\" />填写正确");
	                              },1000);
	      userpassTwoState="0";
	        }
	        
	  }
	  
	  });
	  
	  
$("#userNub").keyup(function(){

	 userpassTwoString = 	$("#userNub").attr("value");
	 if(userpassTwoString.length==4)
	 {
	 
	  if(userpassTwoString!=usergetRandom)
	 {$("#userNub").parents("li").find("span").html("<img src=\"../images/user/spinner.gif\" />");
	  setTimeout(function(){
	  $("#userNub").parents("li").find("span").html("<img src=\"../images/user/exclamation.gif\" />验证码出错");
	  },1000);
	  usergetRandomstate="-2";
	 //alert(""+userpassTwoString+","+usergetRandom+"");
	  }
	  else
	  {   
	   $("#userNub").parents("li").find("span").html("<img src=\"../images/user/spinner.gif\" />");
	         setTimeout(function(){
	         $("#userNub").parents("li").find("span").html("<img src=\"../images/user/drop-yes.gif\" />正确");
	                              },1000);
	        usergetRandomstate="0";
	  }
	 }
	 
	 else if(userpassTwoString.length<4)
	  {
	  $("#userNub").parents("li").find("span").html("<img src=\"../images/user/icon-info.gif\" />");
	  usergetRandomstate="-2";
	  }
	 
	
	  
	  });

$("#userNub").next().next().click(function(){
$("#userNub").next().html(getuserRandoM());
usergetRandom=getuserRandoM();
usergetRandomstate="-2";
$("#userNub").parents("li").find("span").html("<img src=\"../images/user/icon-info.gif\" />");
$("#userNub").attr("value","");

});
	  
	  
	  

});



