var flag = [1,1,1,1,1,0,0];
function checkUsername(username,qingshuruyonghuming,jianchashifouchongfu){	
	 // var username=document.getElementById("username").value;
	  var reId =  /([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[_\a-zA-Z0-9]){3,19}$/;
	  var b_id = reId.test(username);
	  if (!b_id) {
		document.getElementById("userName_note"). innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+qingshuruyonghuming+"</font>";
		flag[0] = 1;
	} else{
		document.getElementById("userName_note"). innerHTML = "<img src='./images/yesok.gif'/> <font color=#ee9955>"+jianchashifouchongfu+"</font>";
	    flag[0] = 0;
	}		
}
function checkPassword(password,mimahefa,zhengquedemima){	
	 // var password=document.getElementById("password").value;
	  var pwId =  /([\uFE30-\uFFA0]|[_\a-zA-Z0-9]){6,19}$/;
	  var p_id = pwId.test(password);
	  if (!p_id) {
		document.getElementById("passWord_note"). innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+zhengquedemima+"</font>";
	flag[1] = 1;
	} else{
		document.getElementById("passWord_note"). innerHTML = "<img src='./images/yesok.gif'/> <font color=#ee9955>"+mimahefa+"</font>";
	      flag[1] = 0;
	}		
}
function checkSecondpassword(seco,ercimimazhongru,mimahefa){ 
      var password=document.getElementById("password"). value 
      //取出第一个文本框里输入的密码一 
      var secondPassword=document.getElementById("secondPassword"). value 
      //取出第二个文本框里输入的密码二 
      if(password!=secondPassword) 
      //2个密码值比较，做判断 
      {
      
       document.getElementById("SecondPassword_note"). innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+ercimimazhongru+"</font>"; 
       //输出对话框提示 
       flag[2] = 1;
      
      } else 
       //否则
       { 
        document.getElementById("SecondPassword_note"). innerHTML = "<img src='./images/yesok.gif'/> <font color=#ee9955>"+mimahefa+"</font>"; 
       //输出对话框提示

        flag[2] = 0;
      } 
} 
 function checkEmail(email,youxiangbuhefa,youxiangkeyong){	
	 // var email=document.getElementById("email").value;	 
	  var emId =  /(^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$)/ ; ;
	  var e_id = emId.test(email);
	  if (!e_id) {
	document.getElementById("Email_note"). innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+youxiangbuhefa+"</font>";
	  flag[3] = 1;
	} else{
		document.getElementById("Email_note"). innerHTML = "<img src='./images/yesok.gif'/> <font color=#ee9955>"+youxiangkeyong+"</font>";
	    flag[3] = 0;
	}
}

function checkAgree(bixutongyixieyi){
	  var aaa=document.getElementsByName("agree");
	  var bbb="";
	  for(var i=0;i<2;i++){
	      if(aaa[i].checked){  
			//alert(aaa[i].value);
		   var bbb=aaa[i].value;
			   if(bbb==1){
				document.getElementById("agree_note"). innerHTML ="";
		 		flag[4] = 0;
			    }else{
			    flag[4] = 1;
			 	document.getElementById("agree_note"). innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+bixutongyixieyi+"</font>";	
		        }
	       }  
	    }	
   }	  
	  
function registSubmit(bixutongyixieyi,qingshuruyonghuming,mimahefa,zhengquedemima,youxiangbuhefa,youxiangbuhefa,bixutongyixieyi){

      var username=document.getElementById("username").value;
	  var reId =  /([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[_\a-zA-Z0-9]){3,19}$/;
	  var b_id = reId.test(username);
	  if (!b_id) {
		document.getElementById("userName_note"). innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+qingshuruyonghuming+"</font>";
		flag[0] = 1;
	}else{
	    flag[0] = 0;
	}
      var password=document.getElementById("password").value;
	  var pwId =  /([\uFE30-\uFFA0]|[_\a-zA-Z0-9]){6,19}$/;
	  var p_id = pwId.test(password);
	  if (!p_id) {
		document.getElementById("passWord_note"). innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+zhengquedemima+"</font>";
	      flag[1] = 1;
	  }
	  
      var secondPassword=document.getElementById("secondPassword"). value 
      //取出第二个文本框里输入的密码二 
      if(password!=secondPassword) 
      //2个密码值比较，做判断 
      {
       document.getElementById("SecondPassword_note"). innerHTML = "<img src='./images/yesno.gif'/><font color=red>二次密码输入不一致</font>"; 
       flag[2] = 1;
      } 
	   
	  var email=document.getElementById("email").value;
	  var emId = /(^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$)/ ;
	  var e_id = emId.test(email);
	  if (!e_id) {
	   document.getElementById("Email_note"). innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+youxiangbuhefa+"</font>";
	  flag[3] = 1;
	  }else{
	    flag[3] = 0;
	} 
	  var aaa=document.getElementsByName("agree");
	  var bbb="";
	  for(var i=0;i<2;i++){
	      if(aaa[i].checked){  
			//alert(aaa[i].value);
		   var bbb=aaa[i].value;
			   if(bbb==1){
				document.getElementById("agree_note"). innerHTML ="";
		 		flag[4] = 0;
			    }else{
			    flag[4] = 1;
			 	document.getElementById("agree_note"). innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+bixutongyixieyi+"</font>";	
		        }
	       }  
	    }
	    
	if(flag[0]==1||flag[1]==1||flag[2]==1||flag[3]==1||flag[4]==1){
        var content='';
	    if(flag[0]==1){
	     var content="用户名格式有误"+'\n';
	    }
	    if(flag[1]==1){
	     var content=content+"密码格式有误"+'\n';
	    }
	    if(flag[2]==1){
	     var content=content+"密码输入不一致"+'\n';
	    }
	    if(flag[3]==1){
	     var content=content+"邮箱格式有误"+'\n';
	    }
	    if(flag[4]==1){
	     var content=content+"注册用户必须同意协议"+'\n';
	    }
		alert (content);
	    return false;
	}
	else{
	//document.getElementById("passWord_note").innerHTML = "<font color=red>登录名或密码错误</font>";    
	}
}



var flag2 = [1,1,1,1,1,1,1];
function checkUsername1(username,qingshuruyonghuming,yonghuminghefa){	
	 // var username=document.getElementById("username").value;
	  var reId =  /([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[_\a-zA-Z0-9]){2,19}$/;
	  var b_id = reId.test(username);
	  if (!b_id) {
		document.getElementById("userName_note").innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+qingshuruyonghuming+"</font>";
	   flag2[0]=1;
	} else{
		document.getElementById("userName_note").innerHTML = "<img src='./images/yesok.gif'/> <font color=#ee9955>"+yonghuminghefa+"</font>";
		flag2[0]=0;
	}
		
}
 function checkEmail1(email,youxiangbuhefa1,youxiangkeyong1){	
	 // var email=document.getElementById("email").value;
	  var emId = /(^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$)/ ;
	  var e_id = emId.test(email);
	  if (!e_id) {
		document.getElementById("Email_note").innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+youxiangbuhefa1+"</font>";
	   flag2[1]=1;
	} else{
		document.getElementById("Email_note").innerHTML = "<img src='./images/yesok.gif'/> <font color=#ee9955>"+youxiangkeyong1+"</font>";
		flag2[1]=0;
	}
		
}
function registSubmit2(qingwanshanyemianxinxi){

	if(flag2[0]==1||flag2[1]==1){
	alert (qingwanshanyemianxinxi);
	return false;
	}
	else{
		//alert ("请完善注册信息")
		//document.getElementById("registError").innerHTML = "<font color=red>请完善注册信息</font>";
	    //return false;
	}
}
var flag1 = [0,0,0,0,0,0,0];
 function checkUsername2(username,qingshuruzhengqueyonghuminggeshi,yonghuminggeshihefa){	
	 // var username=document.getElementById("username").value;
	// alert(username);
	  var reId =  /([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[_\a-zA-Z0-9]){3,19}$/;
	  var b_id = reId.test(username);
	  if (!b_id) {
	  //return false;
	document.getElementById("userName_note").innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+qingshuruzhengqueyonghuminggeshi+"</font>";
	} else{
	  //return true;
	   document.getElementById("userName_note").innerHTML = "<img src='./images/yesok.gif'/> <font color=#ee9955>"+yonghuminggeshihefa+"</font>";
	    flag1[0] = 1;
	}
		
}
function checkPassword1(password,qingshuruzhengquemimageshi,mimageshihefa){	
	 // var password=document.getElementById("password").value;
	  var pwId =  /([\uFE30-\uFFA0]|[_\a-zA-Z0-9]){6,19}$/;
	  var p_id = pwId.test(password);
	  if (!p_id) {
		//return false;
		document.getElementById("passWord_note").innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+qingshuruzhengquemimageshi+"</font>";
	} else{
	  //return true;
	  document.getElementById("passWord_note").innerHTML = "<img src='./images/yesok.gif'/> <font color=#ee9955>"+mimageshihefa+"</font>";
	      flag1[1] = 1;
	}
		
}
function registSubmit1(){

	if(flag1[0]==1&flag1[1]==1){
	//document.getElementById("passWord_note").innerHTML = "<img src='./images/yesno.gif'/><font color=red>请输入正确的密码格式</font>";	
	}
	else{
		alert ("登录名或密码格式不合法")
	//document.getElementById("passWord_note").innerHTML = "<font color=red>登录名或密码错误</font>";
	    return false;
	}
}
$(document).ready(function() {
	$("#username").blur(function(){
	 
		var userName=document.getElementById("username").value;	
		var qingshuruyonghuming=document.getElementById("qingshuruyonghuming").value;	
		var yonghumingkeyong=document.getElementById("yonghumingkeyong").value;	
		var yonghumingzhongfu=document.getElementById("yonghumingzhongfu").value;	
	  var reId =  /([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[_\a-zA-Z0-9]){2,19}$/;
	  var b_id = reId.test(userName);
	  if (!b_id) {
		document.getElementById("userName_note").innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+qingshuruyonghuming+"</font>";
	} else{
		$.post("./checkUsername.php", {username:userName},function(data){	
				
			if(data==1){
				
					flag[0]=0;
					document.getElementById("userName_note").innerHTML = "<img src='./images/yesok.gif'/> <font color=#ee9955>"+yonghumingkeyong+"</font>";
				
			}else{
				flag[0] = 1;
				document.getElementById("userName_note").innerHTML = "<img src='./images/yesno.gif'/><font color=red>"+yonghumingzhongfu+"</font>";
			}
		});
	}
		
	});
});



