// JavaScript Document
//用户注册
var c_email= /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
var reg4=/^[a-zA-Z\d-]*$/;
function setmsg(spanid,alerttext)
{
	$("#"+spanid).html("<img src='images/al.gif' /> <font color=#ff0000>"+alerttext+"</font>");
	return false;
}
function setokmsg(spanid)
{
	$("#"+spanid).html("<img src='images/check_right.gif' />");
	return false;
}
function chkregusername()
{
	var username=$("#username").val();
	if(username=="")
	{
		setmsg("chkusername","用户名不能为空！");
		return false;
	}
	else if(!reg4.test(username))
	{
	    setmsg("chkusername","格式不正确！请使用英文/数字，或以上混合，可带 - 字符！");
	    return false;
    }
	else
	{
		chkusername(username);
	}
}
function chkusername(username)
{
	$("#chkusername").html("<img src='images/loading.gif' /> <font color=#ff0000>检测中...！</font>");
	$("#chkusername").load("chkuserreg.asp?type=chkuser&key="+username);
}
function chkuserpwd()
{
	var pwd1=$("#password").val();
	if(pwd1=="")
	{
		setmsg("chkpwd1","密码不能为空！");
		return false;
	}
	else if(pwd1.length<4)
	{
		setmsg("chkpwd1","密码必须大于4位！");
		return false;
	}
	else
	{
		setokmsg("chkpwd1");
	}
}
function chkuserpwd1()
{
	var pwd1=$("#password").val();
	var pwd2=$("#password2").val();
	if(pwd2=="")
	{
		setmsg("chkpwd2","确认密码不能为空！");
		return false;
	}
	else if(pwd1!=pwd2)
	{
		setmsg("chkpwd2","确认密码不一致！");
		return false;
	}
	else if(pwd1=pwd2)
	{
		setokmsg("chkpwd2");
	}
}
function chkusermobile()
{
	var mobile=$("#mobile").val();
	if(mobile=="")
	{
		setmsg("chkmobile","手机号码不能为空！");
		return false;
	}
	else if(mobile.length!=11)
	{
		setmsg("chkmobile","手机号码必须为11位数字！");
		return false;
	}
	else if(isNaN(mobile))
	{
		setmsg("chkmobile","手机号码必须数字！");
		return false;
	}
	else
	{
		setokmsg("chkmobile");
	}
}
function chkuseremail()
{
	var email=$("#email").val();
	if(email=="")
	{
		setmsg("chkemail","邮箱不能为空！");
		return false;
	}
	else if(!c_email.test(email))
	{
		setmsg("chkemail","邮箱格式不正确！");
		return false;
	}
	else
	{
		$("#chkemail").html("<img src='images/loading.gif' /> <font color=#ff0000>检测中...！</font>");
		$("#chkemail").load("chkuserreg.asp?type=chkemail&key="+email);
	}
}
function chkregform()
{
	var username=$("#username").val();
	var pwd1=$("#password").val();
	var pwd2=$("#password2").val();
	var mobile=$("#mobile").val();
	var email=$("#email").val();
	if(username=="")
	{
		setmsg("chkusername","用户名不能为空！");
		return false;
	}
	if(pwd1=="")
	{
		setmsg("chkpwd1","密码不能为空！");
		return false;
	}
	if(pwd2=="")
	{
		setmsg("chkpwd2","确认密码不能为空！");
		return false;
	}
	if(mobile=="")
	{
		setmsg("chkmobile","手机号码不能为空！");
		return false;
	}
	if(email=="")
	{
		setmsg("chkemail","邮箱不能为空！");
		return false;
	}
}