$(document).ready(
		function() {
		    var emailValid = false;
		    var pwdValid = false;
		    var repwdValid = false;
		    var nicknameValid = false;
		    $('#txtEmail').blur(
				function() {
				    var temp = document.getElementById("txtEmail");
				    //对电子邮件的验证
				    var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
				    if (!myreg.test(temp.value)) {
				        $('#resEmail').html('<font color="red">邮件格式不正确！</font>');
				        emailValid = false;
				        //$('#txtEmail').focus();
				        return;
				    }

				    //格式验证通过，开始验证重复注册
				    $.ajax({
				        url: '/ajax/CheckEmail.ashx?email=' + $('#txtEmail').val(),
				        type: 'GET',
				        dataType: 'text',
				        timeout: 5000,
				        error: function() {
				            emailValid = false;
				            document.getElementById("resEmail").innerHTML = '<font color="red">验证邮箱出错，请重新输入Email</font>';
				            return;
				        },
				        success: function(data) {
				            if (data == 1) { emailValid = false; $('#resEmail').html('<font color="red">该邮件已被注册</font>'); }
				            else if (data == 2) { emailValid = false; $('#resEmail').html('<font color="red">无效邮箱！</font>'); }
				            else {
				                emailValid = true;
				                $('#resEmail').html('该邮件可正常使用');

				            }
				        }
				    });

				}
			);


		    $('#nickName').blur(
		    function() {
		        if ($('#nickName').val().length < 1 || $('#nickName').val().length > 12) {
		            $('#nickName_msg').html('<font color="red">昵称请使用1-12个字符</font>');
		            nicknameValid = false;
		        }
		        else {
		            nicknameValid = true;
		            $('#nickName_msg').html('');
		        }
		    }
		);

		    $('#txtPwd').blur(
		    function() {
		        if ($('#txtPwd').val().length < 6) {
		            $('#resPwd').html('<font color="red">密码长度不能少于6位</font>');
		            pwdValid = false;
		        }
		        else if ($('#txtPwd').val().length > 16) {
		            $('#resPwd').html('<font color="red">密码长度仅限于6-16位</font>');
		            pwdValid = false;
		        }
		        else {
		            pwdValid = true;
		            $('#resPwd').html('');
		        }
		    }
		);
		    $('#txtRePwd').blur(
		    function() {
		        if ($('#txtRePwd').val() != $('#txtPwd').val()) {
		            $('#resRePwd').html('<font color="red">两次密码输入不一致</font>');
		            $('#txtRePwd').val('');
		            $('#txtPwd').select();
		            repwdValid = false;
		        } else {
		            repwdValid = true;
		            $('#resRePwd').html('');
		        }
		    }
		);
		    $('#form1').submit(
		    function() {
		        var prot = document.getElementById("protocol");
		        if (!emailValid || !pwdValid || !repwdValid || !nicknameValid || !prot.checked) {
		            $('#txtEmail').focus();
		            return false;
		        }
		        return true;
		    }

		);

		}
	);