// JavaScript Document

function submit_action(addr)
{
	 document.form1.action=addr;
}
	   
function test()
{
	   document.getElementById("checkinfo").innerHTML="延时1秒";
}

function jscheck_str(str)
{
		var retCode;
		
		if (str.length<3)
		{
		  alert('提示：用户昵称至少应当3个字符以上,英文字母+数字，最多50个字符.');
		  document.form1.user_ni.focus();
		  return false;	
		}
		
		var url;
	    url=window.location.href;
        //alert(window.location.href);
        var point;
	    point=url.lastIndexOf('/')+1;
        var strstr= url.substring(0,point);
        //url 除过最后的文件------------------
	    //alert(str);
		
		infoBoard=document.getElementById("checkinfo"); 
        infoBoard.innerText='查询中...'; 
        myurl=strstr+"check_str.php?str="+str;
		//myurl=myurl+"&answer="+answer;
		//alert(myurl);
        retCode=openUrl(myurl); 
        //alert("服务器返回值："+retCode);
				
        switch(retCode)
	    { 
		
       case "-2": 
                infoBoard.innerHTML='<font color=red>查询中...</font>';
				break; 
				
        case "1": 
                infoBoard.innerHTML='<font color=red>该用户名已经存在！</font>';
				//setTimeout(test,1000);//延时1秒
				document.form1.user_ni.value="";
				document.form1.user_ni.focus();
				break; 
				
        case "0": 
                infoBoard.innerHTML='<font color=red>恭喜！该用户名可以注册！</font>'; 
				//setTimeout(test,1000);//延时1秒
       } 
	   
       return; 
} 

function openUrl(url)
 
 { 
    var objxml=new ActiveXObject("Microsoft.XMLHttp") 
    objxml.open("GET",url,false); 
    objxml.send(); 
    retInfo=objxml.responseText; 
    if (objxml.status=="200")
	{ 
      return retInfo; 
    } 
    else
	{ 
      return "-2"; 
     } 
} 




function check_pass1(str)
{
     var abc;
	 var table1="!@#$%^&*()";
	 var table2="ABCDEFDHIJKLMNOPQRSTUVWXYZ";
	 var table3="1234567890"
	 
	
	for(i=1;i<10;i++)
	{
	  abc=str.indexOf(table1.charAt(i));
	  //alert(table1.charAt(i));
	  if (abc>0)
	  {
		document.getElementById('p1').innerHTML="<font color=#ff00ff size=-1>混合特殊字符</font>";  
	  }
	}
	
	for(i=1;i<10;i++)
	{
	  abc=str.indexOf(table2.charAt(i));
	  //alert(table1.charAt(i));
	  if (abc>0)
	  {
		document.getElementById('p1').innerHTML="<font color=#FF0000 size=-1>混合大写密码</font>";  
	  }
	}
	
	for(i=1;i<10;i++)
	{
	  //abc=str.indexOf(table3.charAt(i));
	  //alert(table1.charAt(i));
	  if (abc>0)
	  {
		//document.getElementById('tip').innerHTML="<font color=#ff0000 size=-1>低密码强度</font>";  
	  }
	}
	
	if (document.form1.pass1.value.length<=3)
	 {
		 document.getElementById('p1').innerHTML="<font color=#ff0000 size=-1><b>密码强度低</b></font>";
	 }
	
	 if ((document.form1.pass1.value.length>3) && (document.form1.pass1.value.length<=6) )
	 {
		 document.getElementById('p1').innerHTML="<font color=#ff0000 size=-1><b>密码强度中</b></font>";
	 }
	 
	 if (document.form1.pass1.value.length>6) 
	 {
		 document.getElementById('p1').innerHTML="<font color=#ff0000 size=-1><b>密码强度高</b></font>";
	 }
	
	 
	 if (form1.pass1.value!=form1.pass2.value)
	 {
		 document.getElementById('p2').innerHTML="<font color=#ff0000 size=-1><b>前后不一致</b></font>";
	 }
	 
	 if (form1.pass1.value==form1.pass2.value)
	 {
		 document.getElementById('p2').innerHTML="<font color=#009966 size=-1><b>前后一致</b></font>";
		 
	 }
		 
}




function check_pass2(str)	 
{
	 	
	if (form1.pass1.value!=form1.pass2.value)
	 {
		 document.getElementById('p2').innerHTML="<font color=#ff0000 size=-1><b>前后不一致</b></font>";
	 }
	 
	 if (form1.pass1.value==form1.pass2.value)
	 {
		 document.getElementById('p2').innerHTML="<font color=#009966 size=-1><b>密码前后一致</b></font>";
		 
	 }
	
}

function check_em(str)
{
	var a;
	var b;
	
	for(i=0;i<str.length;i++)
	{
	  a=str.indexOf("@");
	  b=str.indexOf(".");
	  //alert(table1.charAt(i));
	  if ((a>0) && (b>0))
	  {
		document.getElementById('em').innerHTML="<font color=#009966 size=-1><b>邮件格式正确<b></font>"; 
		 
	  }
	  else
	  {
		document.getElementById('em').innerHTML="<font color=#ff0000 size=-1><b>邮件格式不正确<b></font>"; 
		document.form1.email.value="";
		document.form1.email.focus();   
	  }
	}
}





function check_qq(str)
{
	var table="0123456789";
	var e;
	var c;
	var flag=2;
	if (str.length<=0) 
	{
		return false;
	}
	for(e=0;e<str.length;e++)
	{
		c=str.charAt(e);
		d=table.indexOf(c);
		if(d<0)
		{
			flag=1;
			break;
		}
	
	}
	
	
	if(flag==1)
	{
	document.getElementById('qq_info').innerHTML="<font color=#ff0000 size=-1>QQ号码格式不正确</font>"; 
	document.form1.qq.value="";
	document.form1.qq.focus();	
	
	}
	if(flag==2)
	{
		document.getElementById('qq_info').innerHTML="<font color=#009966 size=-1>QQ号码格式正确</font>";
		
	}
	
	
	
}



function check_phone(str)
{
	var table="0123456789";
	var e;
	var c;
	var flag=2;
	if (str.length<=0) 
	{
		return false;
	}
	for(e=0;e<str.length;e++)
	{
		c=str.charAt(e);
		d=table.indexOf(c);
		if(d<0)
		{
			flag=1;
			break;
		}
	
	}
	
	
	if(flag==1)
	{
	document.getElementById('phone_info').innerHTML="<font color=#ff0000 size=-1>手机号码格式不正确</font>"; 
	document.form1.phone.value="";
	document.form1.phone.focus();	
	
	}
	if(flag==2)
	{
		document.getElementById('phone_info').innerHTML="<font color=#009966 size=-1>手机号码格式正确</font>";
		
	}
	
	
	
}





function check_submit()
{
	//主要判断是否为空;
	if (document.form1.user_ni.value=="")
	{
		alert('提示：请填写用户名.最好是英文字母+数字组成，长度最大50个字符');
		document.form1.user_ni.focus();
		return false;
		
	}
	else if (document.form1.pass1.value=="")
	{
		alert('请输入密码.');
		document.form1.pass1.focus();
		return false;
	}
	else if (document.form1.pass2.value=="")
	{
		alert('请输入密码.');
		document.form1.pass2.focus();
		return false;
	}
	else if (document.form1.email.value=="")
	{
		alert('请输入电子邮件地址 xxx@yyy.com形式.');
		document.form1.email.focus();
		return false;
	}
	else if (document.form1.qq.value=="")
	{
		alert('请输入QQ号.');
		document.form1.qq.focus();
		return false;
	}
	
	else
	  submit_action("register_user_data.php");
	
}


function login_check_submit()
{
	if(document.form1.user_ni.value=="")
	{
		alert('请输入用户名.');
		document.form1.user_ni.focus();
		return false;
	}
	if(document.form1.pass1.value=="")
	{
		alert('请输入密码.');
		document.form1.pass1.focus();
		return false;
	}
	
}








