function reg_check()
{
	var username = $("#username").val();

	if (username == "")
	{
		alert("请填写您的用户名！");
		$("#username").focus();
		return (false);
	}
	if(username.length<2)
	{
		alert("用户名长度不能小于2位字符！");
		return (false);

	}
   var pattern_cn = /^([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[a-zA-Z0-9]|[\s])*$/gi;
   if (!pattern_cn.test(username))
   {
		alert("用户名只能是中英及数字的组合！");
		return false;
   } 


	var p1 = $("#password").val();
	if (p1 == "")
	{
		alert("请填写您的密码！");
		$("#password").focus();
		return (false);
	}
	if(p1.length<6)
	{
		alert("密码长度不能小于6位字符！");
		return (false);

	}

	var p2 = $("#re_password").val();
	if (p2 == "")
	{
		alert("请填写您的密码！");
		$("#re_password").focus();
		return (false);
	}

	if (p1!=p2)
	{
		alert("您两次输入的密码不一致！");
		$("#re_password").focus();
		return (false);

	}

	var useremail = $("#email").val();
	if (useremail == "")
	{
		alert("请填写电子邮箱！");
		$("#email").focus();
		return (false);
	}

	if (!isEmail(useremail) )
	{ 
		$("#email").focus();
		return (false);
	}

	var mobile = $("#mobile").val();
	if (mobile == "")
	{
		alert("请填写手机号！");
		$("#mobile").focus();
		return (false);
	}

	var Code = $("#Code").val();
	if (Code == "")
	{
		alert("请填写验证码！");
		$("#Code").focus();
		return (false);
	}
	if(Code.length<4)
	{
		alert("验证码长度不正确！");
		$("#Code").focus();
		return (false);
	}
	if (!$('#agree_term').attr('checked')) {
		alert("请阅读并接受会员制度！");
		return (false);
	}

	$("#J_SubmitBtn").val("正在提交，请等待...");
	$("#J_SubmitBtn").attr("disabled",true);
	$("#div_mesg").css("display","block");
	$.post(
	"/user/Ajax_Reg.asp",
	{
		username: username,
		password: p1,
		password2: p2,
		email: useremail,
		mobile: mobile,
		code:Code
	},
	function (msg) {
		param_array = msg.split(":");
		flag	= (param_array[0]);
		message = param_array[1];

		if (parseInt(flag)>0)
		{
			alert("注册成功，现在转向新地址");
			window.location.href="/"
			return false;
		}
		else
		{
			//alert(message);
			$("#J_SubmitBtn").val("提交注册信息");
			$("#J_SubmitBtn").attr("disabled",false);
			$("#div_mesg").css("display","none");
			$("#show_mesg_p").css("display","block");
			$("#show_mesg_label").html(message);

			return false;

		}
	}
	)

}
function isEmail(s)
{
        if (s.length > 50)
        {
            alert("Email地址长度不能超过50位!");			
            return false;
        }

         var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|int)$"
         var re = new RegExp(regu);
         if (s.search(re) != -1) {
            return true;
         } else {
            alert("请输入有效的E-mail地址！")			
            return false;
         }
}
function RefreshCode(code_type)
{
	$("#veh_image").html("<img src=\"code.asp?code_type="+code_type+"&"+Date()+"\">");
}
//检查是否是中英文数字组合
function isCnAndEnAndNumber(str)
{
   var pattern_cn = /^([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[a-zA-Z0-9]|[\s])*$/gi;
   return pattern_cn.test(str);
}
function login_check()
{
	var username = $("#username").val();

	if (username == "")
	{
		alert("请填写您的用户名！");
		$("#username").focus();
		return (false);
	}
	if(username.length<2)
	{
		alert("用户名长度不能小于2位字符！");
		return (false);

	}

	var p1 = $("#password").val();
	if (p1 == "")
	{
		alert("请填写您的密码！");
		$("#password").focus();
		return (false);
	}


	var Code = $("#Code").val();
	if (Code == "")
	{
		alert("请填写验证码！");
		$("#Code").focus();
		return (false);
	}
	if(Code.length<4)
	{
		alert("验证码长度不正确！");
		$("#Code").focus();
		return (false);
	}

	$("#J_SubmitBtn").val("正在登录，请等待...");
	$("#J_SubmitBtn").attr("disabled",true);
	$("#div_mesg").css("display","block");
	$.post(
	"/user/Ajax_Login.asp",
	{
		username: username,
		password: p1,
		code:Code
	},
	function (msg) {
		param_array = msg.split(":");
		flag	= (param_array[0]);
		message = param_array[1];

		if (parseInt(flag)>0)
		{
			alert("登录成功!");
			window.location.href="/user/"
			return false;
		}
		else
		{
			$("#J_SubmitBtn").val("提交登录信息");
			$("#J_SubmitBtn").attr("disabled",false);
			$("#div_mesg").css("display","none");
			$("#show_mesg_p").css("display","block");
			$("#show_mesg_label").html(message);

			return false;

		}
	}
	)
}
	function change_pwd()
{

	var password = $("#password").val();
	if (password == "")
	{
		alert("请填写旧密码");
		$("#password")[0].focus();
		return false;
	}
	var password1 = $("#password1").val();
	if (password1 == "")
	{
		alert("请填写新密码");
		$("#password1")[0].focus();
		return false;
	}
	var password2 = $("#password2").val();
	if (password1 != password2)
	{
		alert("输入的新密码不相等");
		$("#password2")[0].focus();
		return false;
	}

}
function get_pwd()
{
	var username = $("#username").val();
	if (username == "")
	{
		alert("请填写用户名");
		$("#username")[0].focus();
		return false;
	}
	var email = $("#email").val();
	if (email == "")
	{
		alert("请填写电子邮箱");
		$("#email")[0].focus();
		return false;
	}

}
