var bool = false;
var bool3 = false;
function checkuser(v)
{
	if(v=="")
	{
		$("#u").html("<TABLE WIDTH=300 height=15 BORDER='0' style='border:1px solid #CCCCCC;background-color:#FFF5D8'><TR><TD width=30 align=center valign=middle><img src='../button/err.gif'></TD><TD><font color='red'>用户名不能为空。</font></TD></TR></TABLE>");
		return false;
	}
	$.ajax({type:"post",url:"validateuser.aspx",data:"name="+v,success:function(msg){
		if(msg=="true")
		{
			$("#u").html("<TABLE WIDTH=300 HEIGHT=18 BORDER='0' style='border:1px solid #CCCCCC;background-color:#FFF5D8'><TR><TD width=30 align=center valign=middle><img src='../button/err.gif'></TD><TD><font color='red'>该用户名已被注册了，请更换用户名。</font></TD></TR></TABLE>");
		}
		else
		{
			bool = true;
			$("#u").html("<TABLE WIDTH=300 height=15 BORDER='0' style='border:1px solid #Fb6a01;background-color:#FFF5D8'><TR><TD width=30 align=center valign=middle><img src='../button/right.gif'></TD><TD><font color='#666666'>用户名可以使用。</font></TD></TR></TABLE>");
			
		}
	}})
}
function checkPost(v)
{
	if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(v))
	{
		email(v);
	}
	else
	{
		$("#y").html("<TABLE WIDTH=300 height=15 BORDER='0' style='border:1px solid #CCCCCC;background-color:#FFF5D8'><TR><TD width=30 align=center valign=middle><img src='../button/err.gif'></TD><TD><font color='red'>请填写正确格式的邮箱地址。</font></TD></TR></TABLE>");
	}
}
function email(v){
	$.ajax({type:"post",url:"validatemail.aspx",data:"name="+v,success:function(msg){
		if(msg=="true")
		{
			$("#y").html("<TABLE WIDTH=300 HEIGHT=18 BORDER='0' style='border:1px solid #CCCCCC;background-color:#FFF5D8'><TR><TD width=30 align=center valign=middle><img src='../button/err.gif'></TD><TD><font color='red'>该邮箱已被注册了，请更换邮箱。</font></TD></TR></TABLE>");
		}
		else
		{
			bool3 = true;
			$("#y").html("<TABLE WIDTH=300 height=15 BORDER='0' style='border:1px solid #Fb6a01;background-color:#FFF5D8'><TR><TD width=30 align=center valign=middle><img src='../button/right.gif'></TD><TD><font color='#666666'>邮箱地址填写成功。</font></TD></TR></TABLE>");
		
		}
	}})
}
function check()
{	
	if(!bool)
	{
		checkuser(document.getElementById('txtusername').value);
	}
	if(!bool3)
	{
		checkPost(document.getElementById('txtemail').value);
	}
	if(bool&&bool3)	
		return true;
		
	return false;
}

