var rndno;
var tmpw;
var tmpu;
var poststate=false;
var vstr;

formName="regForm";
actionFormUrl="/passport/login/ActionReg.asp?srnd=";

	function doCancel(){
		rndno="";
		$("rcode").value="";
		//$("msg_rule").style.display="none";
		//$('msg_cont').style.display='none';	
		$("msg_reginfo").style.display="none";
		$("memuser").disabled=false;
		$("checkuser").disabled=false;
		$("password").disabled=false;
		$("cpassword").disabled=false;
		$("email").disabled=false;
		$("btnRegSubmit").disabled=false;
		//$("btnreg").disabled=true;

	}
	function ValidatingUser(){
		
		var tmpstr=$("memuser").value;
		if (trim(tmpstr)=="")
		{
			alert("请填写会员名！");
			$("memuser").focus();
			return false;
		}
		if (tmpstr.length<5||tmpstr.length>20)
		{
			alert("会员代号长度应在5-20个字符之间!");
			$("memuser").focus();
			return false;
		}
		if (checkPunctuation(tmpstr)!="")
		{
			alert("会员名中不能包括标点符号！");
			$("memuser").focus();
			return false;
		}
		if (!isExistChinese(tmpstr))
		{
			alert("会员名中不能中文！");
			$("memuser").focus();
			return false;
		}
		if (checkSensitiveWords(tmpstr)!="")
		{
			alert("会员名中不能使用网上禁售的产品名称！");
			$("memuser").focus();
			return false;
		}
		if (isWhiteWpace(tmpstr))
		{
			alert("会员名中不能使用空格！");
			$("memuser").focus();
			return false;
		}
		if (!isSsnString(tmpstr))
		{
			alert("会员名中不能使用英文、数字以外的字符！");
			$("memuser").focus();
			return false;
		}
		return true;
	}
	function checkUser(){
		if (!ValidatingUser())return false;
		$("checkuser").disabled=true;
		UrlPost("/passport/login/checkUser.asp?user="+$("memuser").value,"hidden_frame");
	}
	function checkRegStr(fid,nid,s){
		var tmp=trim($(fid).value);
		if (tmp=="")
		{
			$(nid).innerHTML=s;
			return false;
		}
	}
	
	function clearRegStr(nid){
		$(nid).innerHTML="";
	}
	
	function chpwd(){
		if (trim($("cpassword").value)!="")
		{		
			if ($("password").value!=$("cpassword").value)
			{
				$("cpnn").innerHTML="×密码两次输入不一致";
			}
		}
	}

	function chisEmail(){
		if (trim($("email").value)!="")
		{	
			if (!isEmail($("email").value))
			{
				$("enn").innerHTML="×Email填写不正确";
			}else if (checkUseEmail()!="False")
			{
				$("enn").innerHTML="×Email已被使用";
			}
		}
	}

	function checkUseEmail(){

		try{
			var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");			
			xmlDoc.async="false";
			xmlDoc.load("/passport/login/checkEmail.asp?email="+$("email").value);
			nodes = xmlDoc.documentElement.childNodes;
			return nodes.item(0).text;
		}catch(err){
			return false;
		}

		return true;	
	}

	function doAction(){
		if (poststate)
		{
			alert("正在提交，请稍等！");
			return false;
		}

		if ($("rcode").value.toUpperCase()!=rndno)
		{
			alert("安全码输入有误，请重新输入！");
			rndno=getRandCode();
			$('rnd').innerHTML=getRandCode();
			$("rcode").value="";				
			$(formName).target="hidden_frame";
			$(formName).action=actionFormUrl+rndno;
			$(formName).submit();
			return false;
		}
		poststate=true;
		$("memuser").disabled=false;
		$("password").disabled=false;
		$("email").disabled=false;
		
		$(formName).action="/passport/login/ActionReg.asp?uds="+$("uds").value+"&v_no="+eval(vstr)+"&rnd="+$("rcode").value.toUpperCase();

		$(formName).target="hidden_frame";//hidden_frame
		$(formName).submit();
	}
	
	function callbackPost(nType,Msg){		
		if(nType!="10002")
			GB_hide();
		if (nType!="50100")
		{
			poststate=false;			
			$("rcode").value="";	
			$("msg_reginfo").style.display="none";
			$("memuser").disabled=false;
			$("checkuser").disabled=false;
			$("password").disabled=false;
			$("cpassword").disabled=false;
			$("email").disabled=false
			$("btnRegSubmit").disabled=false;			
		}
		if(nType=="10000"){
			//登录安全码
			alert(Msg);	
			$("rcode").value="";
			return false;			
			
		}else if(nType=="10002"){
			//用户验证
			$('ucheck').innerHTML=Msg;
			return false;			
			
		}else if(nType=="10003"){
			//用户
			alert(Msg);	
			$('memuser').focus();
			return false;		
			
		}else if(nType=="10005"){
			//用户
			alert(Msg);	
			$('memuser').focus();
			return false;		
			
		}else if(nType=="50100"){
			//验证成功
			//alert("Msg");
			Msg=Msg.split("|");
			tmpw=Msg[1];
			tmpu=Msg[2];
			$("remail").innerHTML=Msg[0];
			//window.location.href="#";
			$("msg_reginfo").style.display="block";
		}
	}

	function doLogin(){
		$("btnLogin").disabled=true;
		UrlPost("/passport/login.asp?ur="+tmpu+"&uw="+tmpw,'_top');
	}

	function doReg(){
		if (poststate)
		{
			alert("正在提交，请稍等！");
			return false;
		}
		
		if (!ValidatingUser())return false;
		
		//密码
		
		if (trim($("password").value)=="")
		{
			alert("密码不能为空！");
			$("password").focus();
			return false;
		}
		if (trim($("cpassword").value)=="")
		{
			alert("确认密码没有填写！");
			$("cpassword").focus();
			return false;
		}
		if (trim($("password").value).length<6 || trim($("password").value).length>20)
		{
			alert("密码长度在6-20个字符之间！");
			$("password").focus();
			return false;
		}
		if (trim($("cpassword").value)!=trim($("password").value))
		{
			alert("密码两次输入不一致！");
			$("password").focus();
			return false;
		}
		//Email
		if (trim($("email").value)=="")
		{	
			alert("Email没有填写");
			$("email").focus();
			return false;
			
		}
		if (!isEmail($("email").value))
		{
			alert("Email填写不正确");
			$("email").focus();
			return false;
		}
		if (checkUseEmail()!="False")
		{
			alert("您填写的Email已经被使用，请另换一个邮箱！");
			$("email").focus();
			return false;
		}
		if((trim($('myt').value)==null||trim($('myt').value)=='')&&(trim($('msn').value)==null||trim($('msn').value)=='')&&(trim($('qq').value)==null||trim($('qq').value)=='')){

			alert("三种联系方式必须选填一种!");
			$('myt').focus();
			return false;
		}	
			
		$("uds").value=$("password").value
		$("password").value=MD5($("password").value);
		$("cpassword").value=$("password").value;

		$("memuser").disabled=true;
		$("checkuser").disabled=true;
		$("password").disabled=true;
		$("cpassword").disabled=true;
		$("email").disabled=true;
		$("btnRegSubmit").disabled=true;
		rndno=getRandCode();
		$(formName).action=actionFormUrl+rndno;
		$(formName).target="hidden_frame";//hidden_frame
		$(formName).submit();
		GB_showCenterNoClose('企发通行证安全码', "/passport/utility/safeCode.asp?rnd="+MD5(rndno),240,580);

		$("rcode").value="";			
			
	}


//安全码
/*
document.writeln("<div id=\"msg_cont\" style=\"position:absolute; top:100px;z-index:1000;width:90%;display:none\">");
document.writeln("	<table width=\"550\" height=\"200\" border=\"0\" align=\"center\" cellpadding=\"40\" cellspacing=\"0\" class=\"tx_box\" style=\"background:#ffffff;border:10px solid #CCE0F5 \">");
document.writeln("		<tr><td>");
document.writeln("		<span style=\"font-size:28px;font-weight:bold;color:#CC0000\">");
document.writeln("			企发通行证注册安全验证:<\/span><br \/><br \/>");
document.writeln("		<span style=\"font-size:14px;color:#333;line-height:25px;\" id=\"msg_hint_info\">请点击登录伪安全码：<INPUT TYPE=\"text\" NAME=\"rcode\" id=\"rcode\" onkeypress=\"keypress();\" onfocus=\"on_focus()\" onblur=\"on_blur()\"><\/span>&nbsp;<span id=\"wrnd\" style=\"font-size:14px;\">伪安全码<\/span>：<span id=\"rnd\" style=\"cursor: hand;\" title=\"用鼠标点击这里，即可自动完成填写！\" onclick=\"javascript:doCopyRnd();\"> <\/span><br \/>");
document.writeln("		<span style=\"font-size:12px;color:blue;\"><b>提示：<\/b>用鼠标<span id=\"msgrnd\">点击伪安全码</span>，即可自动完成填写！<\/span>");
document.writeln("		<br\/>");
document.writeln("		<hr\/>");
document.writeln("		");
document.writeln("		<div align=\"center\">");
document.writeln("		  <input type=\"button\" name=\"btnreg\" id=\"btnreg\" value=\" 立即注册 \" class=\"m\" style=\"height:30px;font-size:16px\" onclick=\"doRegister()\"\/> ");
document.writeln("		  <input type=\"button\" name=\"btncancel\" id=\"rbtnCancel\" value=\" 取 消 \" class=\"m\" style=\"height:30px;font-size:16px\" onclick=\"javascript:doCancel();\"\/>		  ");
document.writeln("		<\/div><\/td>");
document.writeln("		  <\/tr>");
document.writeln("    <\/table>");
document.writeln("<\/div>");
document.writeln("<FORM METHOD=POST name=\"passportreg\" style=\"display:none;\">");
document.writeln("	<input type=\"hidden\" id=\"username\" NAME=\"user\">");
document.writeln("<INPUT TYPE=\"hidden\" id=\"pwd\" NAME=\"pwd\">");
document.writeln("<\/FORM>");
*/
//注册结果提示
document.writeln("<div id=\"msg_reginfo\" style=\"position:absolute; top:100px;z-index:1000;width:90%;display:none\">");
document.writeln("	<table width=\"550\" height=\"200\" border=\"0\" align=\"center\" cellpadding=\"40\" cellspacing=\"0\" class=\"tx_box\" style=\"background:#ffffff;border:10px solid #CCE0F5 \">");
document.writeln("		<tr><td>");
document.writeln("		<span style=\"font-size:28px;font-weight:bold;color:#CC0000\">");
document.writeln("			注册成功，请验证您的Email：<\/span><br \/><br \/>");
document.writeln("		<TABLE cellSpacing=0 cellPadding=0 width=\"94%\" border=0 align=\"center\" style=\"font-size:14px;\">");
document.writeln("		<TBODY>");
document.writeln("		<TR>");
document.writeln("		<TD vAlign=top width=\"95%\"><span style=\"font-size:14px;\"><STRONG><FONT ");
document.writeln("		color=#ff6600>邮箱验证，只需两步！<\/FONT><\/STRONG>请按以下步骤操作! <\/span>");
document.writeln("		<BR><STRONG>第一步：查收验证信<\/STRONG> <BR>我们已发送验证信到：<span id=\"remail\" style=\"font-weight: bold;color:#FF6600;\"> <\/span>； <BR><BR><STRONG>第二步：点击信中确认按钮 ");
document.writeln("		<\/STRONG><BR>点击验证邮件中的“<STRONG>点此确认<\/STRONG>”按钮，即可验证成功！ ");
document.writeln("		<BR><FONT color=#ff6600><SPAN ");
document.writeln("		class=S>注：为确保您的信息安全，验证信的有效期为12小时，逾期须登录后重新验证！<\/SPAN>");
document.writeln("		<BR><BR><span style=\"font-size:18px;font-weight:bold;color:#CC0000\">");
document.writeln("			您可以跳过“邮箱验证”，登录后完善企业资料(30天以内未完善资料,则会删除帐号)、发布商机信息。<\/span>");
document.writeln("		<\/FONT><BR><\/TD><\/TR><\/TBODY><\/TABLE>");
document.writeln("		<br\/>");
document.writeln("		<hr\/>");
document.writeln("		");
document.writeln("		<div align=\"center\">");
document.writeln("		  <input type=\"button\" name=\"btnlogin\" id=\"btnLogin\" value=\" 立即进入企发通行证 \" class=\"m\" style=\"height:30px;font-size:16px\" onclick=\"javascript:doLogin();\"\/>		  ");
document.writeln("		<\/div><\/td>");
document.writeln("		  <\/tr>");
document.writeln("    <\/table>");
document.writeln("<\/div>");