function checkform()
{
	if(document.getElementById("username").value.length<4||document.getElementById("password").value.length<6)
	{
		alert('资料填写不合法，如长度、非常字符...');
		return false;
		}
	else
	{
		return true;
		}
	
	}

function checkpwd(s)
{
	if(s.length<6)
	{
		 document.getElementById("pw1txt").innerHTML="<font color='red' font-size='10'>密码长度不够..</font>";
         return false;
		}
		else
		{
			 document.getElementById("pw1txt").innerHTML="<font color='red' font-size='10'>ok..</font>";
         return true;
			}
}
function checkemail()
{
	var email=document.getElementById("email").value;
    if(!email.match( /^.+@.+$/ ))
		{
			 document.getElementById("emailtxt").innerHTML="<font color='red' font-size='10'>不合法..</font>";
         return false;
			}
			else
			{
				 document.getElementById("emailtxt").innerHTML="<font color='red' font-size='10'>.ok.</font>";
				 return true;
				}
}
function recheckpwd()
{
	var password=document.getElementById("password").value;
	var reputPassword=document.getElementById("reputPassword").value;
	if(reputPassword.length<6)
	{
		document.getElementById("pw2txt").innerHTML="<font color='red' font-size='10'>密码长度不够..</font>";
	return;
	}
	else if (password==reputPassword)
	{
		document.getElementById("pw2txt").innerHTML="<font color='red' font-size='10'>ok..</font>";
	}
	else
	{
		document.getElementById("pw2txt").innerHTML="<font color='red' font-size='10'>密码不一致..</font>";
		}
}

function refreshcode()
{
	//刷新验证码
	document.getElementById("codeimg").src="/common/code.php?type=reg#" + Math.random();
}

function checkcode()
{
	xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
    {
    alert("你的浏览器不支持AJAX！");
    return;
    }

  var url="/reg_ajax.php";
  var code=document.getElementById("code").value;
	
  xmlHttp.onreadystatechange=code_stateChanged;
  xmlHttp.open("get",url+"?do=regcode&code="+code,true);
  xmlHttp.send(null);
	}
	
	function code_stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("codetxt").innerHTML=xmlHttp.responseText;
}
}

function showHint(str)
{


  if (str.length<4)
    { 
      document.getElementById("usertxt").innerHTML="<font color='red' font-size='10'>用户名长度不够..</font>";
    return;
    }
	else if(str.length>16)
	{
		document.getElementById("usertxt").innerHTML="<font color='red' font-size='10'>用户名过长..</font>";
return;
}
	else
	{
		
		document.getElementById("usertxt").innerHTML="<font color='red'>验证中..</font>";
	
	

  xmlHttp=GetXmlHttpObject()

  if (xmlHttp==null)
    {
    alert("你的浏览器不支持AJAX！");
    return;
    }

  var url="/reg_ajax.php";
  
	
  xmlHttp.onreadystatechange=stateChanged;
  xmlHttp.open("get",url+"?do=reguser&user="+str,true);
  xmlHttp.send(null);
}
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("usertxt").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
return xmlHttp;
}
