var xmlhttp
try{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(E)
{
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E)
{
xmlhttp=new XMLHttpRequest();
}
}

function checkuser(user){
	
    if(user.length<2){      
    document.getElementById("showArea").innerHTML ="<span class='checkred'>用户名不得少于2个字符！</span>";
    return false;
    }	
    else
	{
	if(!/^([\u4e00-\u9fa5]|[A-Za-z0-9_])*$/.test(user)) {
	document.getElementById("showArea").innerHTML ="<span class=checkred>用户名应为英文、数字或下划线</span>";							 
	  return false; 
	} 
	
	else
	{
      if(user!=""){
          var oDoc = new ActiveXObject("MSXML2.DOMDocument"); 
          xmlhttp.open("POST", "/register/checkuser.aspx?user="+user+"&type=user", true); 
          xmlhttp.onreadystatechange=checking;
          xmlhttp.send(""); 
         }
    
    }
	}
}

function checking()
{

if(xmlhttp.readystate<4){
 document.getElementById("showArea").innerHTML ="&nbsp;正在查询……";
}
if(xmlhttp.readyState==4){
 
  if(xmlhttp.status == 200)
      {
            result = xmlhttp.responseText; 
            if(parseInt(result)==0){
             document.getElementById("showArea").style.display='';
            document.getElementById("showArea").innerHTML ="<span class=checkgreen>恭喜您!该用户名可以注册</span>";
            //document.getElementById("chk").value="0";
            }
            else if(parseInt(result)>0){
             document.getElementById("showArea").style.display='';
            document.getElementById("showArea").innerHTML ="<span class=checkred>此用户名已经被注册,请重新选择</span>";
            //document.getElementById("chk").value="1";
            }
           }
       else
       {
        
          document.getElementById("showArea").innerHTML = "正在查询数据……";   
        }
}
}

function checking_email()
{

if(xmlhttp.readystate<4){
 document.getElementById("showArea2").innerHTML ="&nbsp;正在查询……";
}
if(xmlhttp.readyState==4){
 
  if(xmlhttp.status == 200)
      {
            result = xmlhttp.responseText; 
            if(parseInt(result)==0){
             document.getElementById("showArea2").innerHTML ="<span class=checkgreen>恭喜您，该Email可以注册！</span>";
            //document.getElementById("chk").value="0";
            }
            else if(parseInt(result)>0){
            document.getElementById("showArea2").innerHTML ="<span class=checkred>抱歉，该Email已被注册。</span>";
            //document.getElementById("chk").value="1";
            }
           }
       else
       {
        
          document.getElementById("showArea2").innerHTML = "正在查询数据……";   
        }
}
}

function checkemail()
{
	 if (addform.mail.value=="")
   {
    document.getElementById("showArea2").innerHTML ="<span class=checkred>请输入Email</span>";
    }
	else
	{
	var   filter=/^\s*([A-Za-z0-9_-]+(\.\w+)*@(\w+\.)+\w{2,3})\s*$/;   
	  if(!filter.test(addform.mail.value))   
	  {   
		document.getElementById("showArea2").innerHTML ="<span class=checkred>输入的Email格式不正确</span>";
	  } 
	  else
	  {
        var oDoc = new ActiveXObject("MSXML2.DOMDocument"); 
          xmlhttp.open("POST", "/register/checkuser.aspx?user="+addform.mail.value+"&type=email", true); 
          xmlhttp.onreadystatechange=checking_email;
          xmlhttp.send("");      }
	}
}

function checkpwd()
{
	if (addform.pass.value=="")
   {
   document.getElementById("showArea3").innerHTML ="<span class=checkred>请输入6-16位的密码</span>";
    }
	else{
	 document.getElementById("showArea3").innerHTML ="<span class=checkgreen>输入正确</span>";
	}
}
function checkpwd2()
{
	 if (addform.pass.value!=addform.pass1.value)
   {
   document.getElementById("showArea4").innerHTML ="<span class=checkred>两次密码输入不一致</span>";
    }
	else
	{
		if(addform.pass1.value.length<6)
		{  
			document.getElementById("showArea4").innerHTML ="<span class=checkred>请输入6-16位的密码</span>";
			 addform.pass.focus();
		}
		else
		{
		 document.getElementById("showArea4").innerHTML ="<span class=checkgreen>输入正确</span>";
		}
	}
}
function checksheng()
{
if (addform.sheng.value=="")
   {
   document.getElementById("showArea6").innerHTML ="<span class=checkred>请选择所在地区</span>";
    }
	else
	 document.getElementById("showArea6").innerHTML ="<span class=checkgreen>选择成功</span>";
}
function checksex()
{
if (addform.colxrsex.value=="")
   {
   document.getElementById("showArea5").innerHTML ="<span class=checkred>请选择您的性别</span>";
    }
	else
	 document.getElementById("showArea5").innerHTML ="<span class=checkgreen>选择成功</span>";
}
function checktruename()
{
if (addform.tbZcCode.value=="" || addform.tbZcCode.value.length<2)
   {
   document.getElementById("showArea7").innerHTML ="<span class=checkred>请填写注册码。<a href='#'>如何获取注册码？</a></span>";
    }
	else
	 document.getElementById("showArea7").innerHTML ="<span class=checkgreen>您已输入。</span>";
}
function checktel()
{
if (addform.cotel.value=="")
   {
   document.getElementById("showArea8").innerHTML ="<span class=checkred>请填写您的联系方式</span>";
    }
	else
	{ 
	if(addform.cotel.value!="")
	{
		if(addform.cotel.value.length<7){
			 document.getElementById("showArea8").innerHTML ="<span class=checkred>电话号码位数不对。</span>";
		}
		else if( isNumberString(addform.cotel.value,"1234567890")!=1) {
			document.getElementById("showArea8").innerHTML ="<span class=checkred>电话号码只能为数字。</span>";
		}
		else
	  {
	 document.getElementById("showArea8").innerHTML ="<span class=checkgreen>输入正确</span>";
	 document.getElementById("showArea9").innerHTML =""; 
		}
	}
	}
}
function checkaddr()
{
if (addform.address.value.length>3)
    document.getElementById("showArea10").innerHTML ="<span class=checkgreen>输入正确</span>";
	else
	document.getElementById("showArea10").innerHTML ="";
}
function checkyb()
{
if (addform.yb.value.length==6)
    document.getElementById("showArea11").innerHTML ="<span class=checkgreen>输入正确</span>";
else
	document.getElementById("showArea11").innerHTML ="";
}
function checkqq()
{
if (addform.qq.value.length>4)
    document.getElementById("showArea12").innerHTML ="<span class=checkgreen>输入正确</span>";
else
 document.getElementById("showArea12").innerHTML ="";
}

function isNumberString (InString,RefString)
{
if(InString.length==0) return (false);
for (Count=0; Count < InString.length; Count++)  {
	TempChar= InString.substring (Count, Count+1);
	if (RefString.indexOf (TempChar, 0)==-1)  
	return (false);
}
return (true);
}