// JavaScript Document
/*Check管理员登录信息*/
function checkAdmin(theForm)
{
	if (theForm.txtUsername.value == "")
	{
		alert("请输入用户名!");
		theForm.txtUsername.focus();
		return false;
	}
	if (theForm.txtPassword.value == "")
	{
		alert("请输入密码！");
		theForm.txtPassword.focus();
		return false;
	}
	if (theForm.checkcode.value == "")
	{
		alert("请输入验证码!");
		theForm.checkcode.focus();
		return false;
	}
	return true;
}

/*Check注册信息*/
function checkRegister(theForm)
{
	if(theForm.txtUserName.value == ""){
		alert("Please enter a user name!");
		theForm.txtUserName.focus();
		return false;
	}
	if(theForm.txtUserName.value.length > 20 || theForm.txtUserName.value.length < 4){
		alert("Member Id 4 to 20 characters (A-Z, a-z, 0-9, no space)");
		theForm.txtUserName.focus();
		return false;
	}
	if(!checkUserName(theForm.txtUserName.value)){
		return false;
	}
	if(theForm.txtPassword.value == ""){
		alert("Please enter your password!");
		theForm.txtPassword.focus();
		return false;
	}
	if(theForm.txtPassword.value.length > 20 || theForm.txtPassword.value.length < 4){
		alert("password 4 to 20 characters (A-Z, a-z, 0-9, no space)");
		theForm.txtPassword.focus();
		return false;
	}
	if(!checkPassword(theForm.txtPassword.value)){
		return false;
	}
	if(theForm.txtPassword.value != theForm.txtPassword_r.value){
		alert("Enter two different passwords!");
		return false;
	}
	if(theForm.txtEmail.value == ""){
		alert("Please fill out the E-mail address!");
		theForm.txtEmail.focus();
		return false;
	}
	if(!checkEmail(theForm.txtEmail.value)){
		return false;
	}
	return true;
}

/*Check用户登录信息*/
function checkUser(theForm)
{
	if (theForm.txtUserName.value == "")
	{
		alert("Please enter a user name!");
		theForm.txtUserName.focus();
		return false;
	}
	if (theForm.txtPassword.value == "")
	{
		alert("Please enter your password!");
		theForm.txtPassword.focus();
		return false;
	}
	return true;
}

function checkEmail(str){
	var patterns = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
	if(!patterns.test(str)){
		alert("Please fill out the legitimate e-mail address!");
		return false;
	}else{
		return true;
	}
}

function checkUserName(str){
	var patterns = /^[a-zA-Z0-9]+$/;
	if(!patterns.test(str)){
		alert("Member Id 4 to 20 characters (A-Z, a-z, 0-9, no space)");
		return false;
	}else{
		return true;
	}
}

function checkPassword(str){
	var patterns = /^[a-zA-Z0-9]+$/;
	if(!patterns.test(str)){
		alert("password 4 to 20 characters (A-Z, a-z, 0-9, no space)");
		return false;
	}else{
		return true;
	}
}