
var regWaitTime = 0;
var regCutWaitFunc = null;
// 检测注册表单
function CheckRegForm(){
	if ($id("username").value==""){alert("用户名不能为空！");$id("username").focus();return false;}
		try {
	if ($id("userpwd").value==""){alert("密码不能为空！");$id("userpwd").focus();return false;}
	if ($id("userpwd").value.length<6){alert("密码长度不能少于6位！");$id("userpwd").focus();return false;}
	if ($id("userpwd").value!=$id("userpwd2").value){alert("密码不一致！");$id("userpwd2").focus();return false;}
		}catch (e){}
	if ($id("mail").value==""){alert("E-mail不能为空！");$id("mail").focus();return false;}
	if (! IsMail($id("mail").value)){alert("E-mail格式错误！");$id("mail").focus();return false;}
		try {
	if ($id("question").value==""){alert("密保问题不能为空！");$id("question").focus();return false;}
	if ($id("answer").value==""){alert("密保答案不能为空！");$id("answer").focus();return false;}
		}catch (e){}

		try {
	if ($name("isAgree")[0].checked==false){
		alert("只有同意注册协议规定，才可提交注册。");$name("isAgree")[0].focus();return false;
	}
		}catch (e){}
		try {
	if ($id("popVerCode").value==""){alert("验证码不能为空.");$id("popVerCode").focus();return false;}
		}catch (e){}

	if (regWaitTime>0){
		alert("已提交，请稍等一会儿...("+ regWaitTime +")");return false;
	}
		regWaitTime = 10;
		regCutWaitFunc = window.setInterval("CutWaitTime()",1000);

//	if (webPathPart=="../"){ $id('regForm').action = webPathPart + $id('regForm').action; }
	AjaxPostDeal("regForm");
	return false;
}

function CutWaitTime(){
	if (regWaitTime<=0){
		window.clearInterval(regCutWaitFunc);
		return false;
	}else{
		regWaitTime --;
	}
}



// 及时检测用户名的合法性
function CheckUserName(username){
	$id("usernameStr").innerHTML="检测中...";
	$.ajaxSetup({cache:false});
	$.get(webPathPart +"users_deal.asp?mudi=checkUserName&method=write&userName="+ escape(username), function(result){
		$id("usernameStr").innerHTML=result;
		if (result.lastIndexOf('green')>=0){
			$id("usernameIsOk").innerHTML="<img src='"+ webPathPart +"inc_img/share_yes.gif' />";
		}else{
			$id("usernameIsOk").innerHTML="<img src='"+ webPathPart +"inc_img/share_no.gif' />";
		}
	});

}


// 及时检测密码的合法性
function CheckUserPwd(){
	if ($id("userpwd").value.length>=6){
		$id("userpwdIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_yes.gif' />";
		$id("userpwdStr").style.display = "none";
	}else{
		$id("userpwdIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_no.gif' />";
		$id("userpwdStr").style.display = "";
		$id("userpwdStr").innerHTML = "长度不足6位，当前长度："+ $id("userpwd").value.length +"";
		return false;
	}
}

// 及时检测确认密码的合法性
function CheckUserPwd2(){
	if ($id("userpwd2").value==""){
		$id("userpwd2IsOk").innerHTML = "";
		$id("userpwd2Str").style.display = "none";
		return false;
	}
	if ($id("userpwd").value.length==$id("userpwd2").value.length){
		$id("userpwd2IsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_yes.gif' />";
		$id("userpwd2Str").style.display = "none";
	}else{
		$id("userpwd2IsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_no.gif' />";
		$id("userpwd2Str").style.display = "";
		$id("userpwd2Str").innerHTML = "两次密码输入不一致";
		return false;
	}
}

// 及时检测昵称的合法性
function CheckNickname(){
	if (Str_IsSign($id("nickname").value)==false){
		$id("nicknameIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_yes.gif' />";
		$id("nicknameStr").style.display = "none";
	}else{
		$id("nicknameIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_no.gif' />";
		$id("nicknameStr").style.display = "";
		$id("nicknameStr").innerHTML = "含不符合要求的字符";
		return false;
	}
}

// 及时检测邮箱的合法性
function CheckMail(){
	if (IsMail($id("mail").value)){
		$id("mailIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_yes.gif' />";
		$id("mailStr").style.display = "none";
	}else{
		$id("mailIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_no.gif' />";
		$id("mailStr").style.display = "";
		$id("mailStr").innerHTML = "格式错误！";
	}
}

// 及时检测问题的合法性
function CheckQuestion(){
	if (Str_IsSign($id("question").value)==false){
		$id("questionIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_yes.gif' />";
		$id("questionStr").style.display = "none";
	}else{
		$id("questionIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_no.gif' />";
		$id("questionStr").style.display = "";
		$id("questionStr").innerHTML = "含不符合要求的字符";
		return false;
	}
	if (Str_Byte($id("question").value)>=2 && Str_Byte($id("question").value)<=50){
		$id("questionIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_yes.gif' />";
		$id("questionStr").style.display = "none";
	}else{
		$id("questionIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_no.gif' />";
		$id("questionStr").style.display = "";
		$id("questionStr").innerHTML = "长度请在2~50字节范围内";
		return false;
	}
}

// 及时检测问题答案的合法性
function CheckAnswer(){
	if (Str_Byte($id("answer").value)>=2 && Str_Byte($id("answer").value)<=50){
		$id("answerIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_yes.gif' />";
		$id("answerStr").style.display = "none";
	}else{
		$id("answerIsOk").innerHTML = "<img src='"+ webPathPart +"inc_img/share_no.gif' />";
		$id("answerStr").style.display = "";
		$id("answerStr").innerHTML = "长度请在2~50字节范围内";
		return false;
	}
}

// 打开/关闭注册协议
function OpenRegNote(){
	if ($id("regNoteK").style.display==""){
		$id("regNoteK").style.display="none";
	}else{
		$id("regNoteK").style.display="";
	}
}







// 登录表单检测
function CheckLoginForm(){
	if ($id("username").value==""){alert("用户名不能为空！");$id("username").focus();return false;}
	if ($id("userpwd").value==""){alert("密码不能为空！");$id("userpwd").focus();return false;}
		try {
	if ($id("verCodeK").style.display==""){
		if ($id("popVerCode").value==""){alert("验证码不能为空.");$id("popVerCode").focus();return false;}	
	}
		}catch (e){}

//	if (webPathPart=="../"){ $id('loginForm').action = webPathPart + $id('loginForm').action; }
	AjaxPostDeal("loginForm");
	return false;
}





// 忘记密码——查找方式
function MissPwdType(){
	for (var i=0; i<$name("refType").length; i++){
		if ($name("refType")[i].checked==true){
			$id("refTypeValue").innerHTML = $name("refType")[i].value
		}
	}
}



// 忘记密码——查找用户名
function MissPwdSend(){
	refType = $id("refTypeValue").innerHTML;
	userData = $id('username').value;
	if (userData == ""){
		alert(refType +"不能为空。");$id('username').focus();return false;
	}
	AjaxGetDealToId(webPathPart +"users_deal.asp?mudi=missPwdSend&refType="+ escape(refType) +"&userData="+ escape(userData),"questionStr");
}



// 忘记密码——表单检测
function CheckMissPwdForm(){
	if (! $id("userID")){ return false; }
	if ($id("userID").value=="" || $id("userID").value=="0"){alert("指定用户错误！");return false;}
	if ($id("answer").value==""){alert("密保答案不能为空！");$id("answer").focus();return false;}

	if ($id("userpwd").value==""){alert("新密码不能为空！");$id("userpwd").focus();return false;}
	if ($id("userpwd").value.length<6){alert("新密码长度不能少于6位！");$id("userpwd").focus();return false;}
	if ($id("userpwd").value!=$id("userpwd2").value){alert("新密码不一致！");$id("userpwd2").focus();return false;}

		try {
	if ($id("popVerCode").value==""){alert("验证码不能为空.");$id("popVerCode").focus();return false;}
		}catch (e){}

//	if (webPathPart=="../"){ $id('missForm').action = webPathPart + $id('missForm').action; }
	AjaxPostDeal("missForm");
	return false;
}


// 忘记密码——发送邮件
function SendMissMail(userID){
	try {
		document.getElementById("loadingStr").innerHTML = "<span style='font-size:14px;'><img src='"+ webPathPart +"inc_img/onload.gif' style='margin-right:5px;' />"+ ajaxDealStr +"</span>";
	}catch (e) {}

	AjaxGetDeal(webPathPart +"users_deal.asp?mudi=missPwdMail&userID="+ userID);
}




// 会员退出
function UserExit(){
	if (confirm('您确定要退出？')==true){
		AjaxGetDeal(webPathPart +'users_deal.asp?mudi=exit');
	}
}