//用下面的变量来返回数据
function check_reg()
{

	
 var filter=/^[a-zA-Z0-9_~!@#$%^&*()]{6,20}$/;
	if (!filter.test(document.register.username.value)) { 
                alert("用户名不能为空，长度不小于6个字符，不超过20个字符。"); 
                document.register.username.focus();
                return (false); 
                } 
	if (!filter.test(document.register.pass.value)) { 
                alert("密码不能为空，长度不小于6个字符，不超过20个字符。"); 
                document.register.pass.focus();
                return (false); 
                }
	if (!filter.test(document.register.confirmpassword.value)) { 
                alert("确认密码不能为空，长度不小于6个字符，不超过20个字符。"); 
                document.register.confirmpassword.focus();
                return (false); 
                } 
	if (document.register.pass.value!=document.register.confirmpassword.value) { 
                alert("密码与确认密码不同。"); 
                document.register.confirmpassword.focus();
                return (false); 
                } 	
	
	if (document.register.nickname.value=="")
	{
		alert("昵称必填！");
		document.register.nickname.focus();
		return false;
	}
	

	if(document.register.email.value.length!=0)
  {
    if (document.register.email.value.charAt(0)=="." ||        
         document.register.email.value.charAt(0)=="@"||       
         document.register.email.value.indexOf('@', 0) == -1 || 
         document.register.email.value.indexOf('.', 0) == -1 || 
         document.register.email.value.lastIndexOf("@")==document.register.email.value.length-1 || 
         document.register.email.value.lastIndexOf(".")==document.register.email.value.length-1)
     {
      alert("电子邮箱格式不正确！");
      document.register.email.focus();
      return false;
      }
   }
 else
  {
   alert("电子邮箱不能为空！");
   document.register.email.focus();
   return false;
   }
  var filter=/^\d{4,4}$/;
 if (!filter.test(document.register.Verifycode.value))
	{
		alert("验证码必须要填写！");
		document.register.Verifycode.focus();
		return false;
	}
	sendRequest("checkuser.asp?username=" + document.register.username.value);
	if (return_str=="0"){
	alert("该用户名已经有人用了，请再选择一个");
	document.register.username.focus();
    document.register.username.select();
    return false
	}
	sendRequest("checkemail.asp?email=" + document.register.email.value);
	if (return_str=="0"){
	alert("该邮箱已经存在，请另选一个");
	document.register.email.focus();
    document.register.email.select();
    return false
	}
}

var return_str=""


xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
function sendRequest(sndStr) 
{ 
var xmlDom = new ActiveXObject("Msxml2.DOMDocument"); 
xmlhttp.open("GET", sndStr, false); 
xmlhttp.onreadystatechange = sendRequest_check; 
xmlhttp.Send(xmlDom); 
}
//-------------------------------------------------------- 
function sendRequest_check() 
{ 
	var state = xmlhttp.readyState; 
	
	var xmlDom = new ActiveXObject("Msxml2.DOMDocument"); 

	if (state == 4) 
	{ 
	xmlDom.loadXML(xmlhttp.responseXML.xml); 
	return_str = xmlDom.documentElement.selectSingleNode("//objXML").text;
	} 
} 



function check_user_input(thisinput)
{
	var re = /^[a-zA-Z1-9_]{6,20}$/;
	if ( (thisinput.value.trim() == "") ) {
		reguserinfo.className = "show null";
		reguserinfo.innerHTML = "系统未检测到您的输入";
	}
	else if (!thisinput.value.match(re))
	{
		reguserinfo.className = "show err";
		reguserinfo.innerHTML = "输入不符合规范";
	}
	else
	{
	sendRequest("checkuser.asp?username=" + thisinput.value);
		if (return_str=="0")
		{
			reguserinfo.className = "show err";
			reguserinfo.innerHTML = "该用户名已经存在，请另换一个";
		}
		else
		{
			reguserinfo.className = "show exactness";
			reguserinfo.innerHTML = "恭喜你，可以使用该用户名";
		}
	}
}
function click_user_input(thisinput)
{
	reguserinfo.className = "show exactness";
	reguserinfo.innerHTML = "填写6～20位英文、数字或下划线";
}
//mouse lost the password box
function check_password_input(thisinput)
{
	var count = thisinput.value.trim().ByteCount();

	if (thisinput.value.trim() == "") {
		regpassinfo.className="show null";
		regpassinfo.innerHTML="系统未检测到您的输入";
	}
	else if (count < 6 || count > 20)
	{
		regpassinfo.className = "show err";
		regpassinfo.innerHTML = "输入不符合规范";
	}
	else
	{
		regpassinfo.className = "show exactness";
		regpassinfo.innerHTML = "内容符合规范，可以使用";
	}
}
function click_password_input(thisinput)
{
	regpassinfo.className = "show exactness";
	regpassinfo.innerHTML = "填写6～20位的密码";
}
function check_chkpass_input(thisinput)
{
	var oPass = register.pass.value;
	if(thisinput.value.trim() == "")
	{
		regpass2info.className="show null";
		regpass2info.innerHTML = "系统未检测到您的输入";
	}
	else if(thisinput.value != oPass)
	{
		regpass2info.className="show err";
		regpass2info.innerHTML = "确认密码与密码不一致";
	}
	else
	{
		regpass2info.className = "show exactness";
		regpass2info.innerHTML = "密码确认通过";
	}
}
//mouse onclick the chkpass box
function click_chkpass_input(thisinput)
{
	var oPass = register.pass.value;
	if( oPass == "")
	{
		register.pass.focus();
	}else{
		regpass2info.className="show exactness";
		regpass2info.innerHTML="请输入确认密码";
	}
}

String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

//Count string byte number, return integer
String.prototype.ByteCount = function()
{
	txt = this.replace(/(<.*?>)/ig,"");
	txt = txt.replace(/([\u0391-\uFFE5])/ig, "11");
	var count = txt.length;
	return count;
}

function check_nickname_input(thisinput)
{
	if (thisinput.value.trim() == "") {
		regnicknameinfo.className="show null";
		regnicknameinfo.innerHTML="系统未检测到您的输入";
	}
	else
	{
		regnicknameinfo.className = "show exactness";
		regnicknameinfo.innerHTML = "内容符合规范，可以使用";
	}
}
function click_nickname_input(thisinput)
{
	regnicknameinfo.className = "show exactness";
	regnicknameinfo.innerHTML = "填写昵称";
}
function click_email_input(thisinput)
{
	regemailinfo.className="show exactness";
	regemailinfo.innerHTML="请填写电子邮箱，非常重要";
}
//mouse lost the email box
function check_email_input(thisinput)
{
	var re = /^[_a-zA-Z0-9\-\.]+@([\-_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/;
	if ( (thisinput.value.trim() == "") ) {
		regemailinfo.className = "show null";
		regemailinfo.innerHTML = "系统未检测到您的输入";
	}
	else if (!thisinput.value.match(re))
	{
		regemailinfo.className = "show err";
		regemailinfo.innerHTML = "输入不符合规范";
	}
	else
	{
			sendRequest("checkemail.asp?email=" + thisinput.value);
		if (return_str=="0")
		{
			regemailinfo.className = "show err";
			regemailinfo.innerHTML = "该邮箱已经存在，请另换一个";
		}
		else
		{
			regemailinfo.className = "show exactness";
			regemailinfo.innerHTML = "该邮箱可以使用";
		}
	}
}
function click_Verifycode_input(thisinput)
{
	regVerifycodeinfo.className="show exactness";
	regVerifycodeinfo.innerHTML="请填写小图片中的数字";
}
function check_Verifycode_input(thisinput)
{
	var count = thisinput.value.trim().ByteCount();
	if ( (thisinput.value.trim() == "") ) {
		regVerifycodeinfo.className = "show null";
		regVerifycodeinfo.innerHTML = "系统未检测到您的输入";
	}
	else if (count!=4)
	{
		regVerifycodeinfo.className = "show err";
		regVerifycodeinfo.innerHTML = "输入不符合规范";
	}
	else
	{
		regVerifycodeinfo.className = "show exactness";
		regVerifycodeinfo.innerHTML = "内容符合规范，可以使用";
	}
}
function click_qq_input(thisinput)
{
	regqqinfo.className="show exactness";
	regqqinfo.innerHTML="只是方便客服联系";
}
//mouse lost the email box
function check_qq_input(thisinput)
{
		regqqinfo.className = "noshow";
		regqqinfo.innerHTML = "";
}