var chkU=false,chkP=false,chkCode=false;var chkUser=false,chkPassword=false,chkPassword1=false,chkEmail=false;function setHeight(){var a=setInterval("setUser()",100);this.setUser=function(){if(headerLogin){clearInterval(a);$("u1").value=headerUserName}};document.logForm.onkeyup=logSubmit;document.regForm.onkeyup=regSubmit;var b=location.search.toLowerCase().replace("?","");if(b!=""){refreshURL=b.replace("reg|||","")};if(!refreshURL||refreshURL=="reg"||refreshURL=="")refreshURL=document.referrer;if(refreshURL==""||refreshURL.indexOf("proxy.htm")>0)refreshURL="http://www.toufa.com/userInfo.html";Element.cleanWhitespace('login');var c=0;if(b.split("|||")[0]=="reg"){c=1};var d=document.getElementsByClassName('box');var e=document.getElementsByClassName('tab');var f=new fx.Accordion(e,d,{opacity:false,height:true,duration:600});var g=false;f.showThisHideOpen(d[c]);$("login1").appendChild($("login2").getElementsByTagName("div")[0])}function logSubmit(a){var e=a||window.event;if(e.keyCode==13){chkLogin()}}function regSubmit(a){var e=a||window.event;if(e.keyCode==13){chkReg()}}function chgCode(){var a="http://bbs.toufa.com/DV_getcode.asp?";$("code1").setAttribute("src",a+(new Date()).getTime());if(isIE){$("code2").setAttribute("src",a+"fresh=reg")}else{$("code2").setAttribute("src",a+(new Date()).getTime())}}function regChkUser(a){var b=$("u2").value.trim();$("u2").value=b;if(b.length<4){if(a!=null)$("u2").focus();chkUser=false;showErr("","您输入的用户名太短！")}else{showErr('','');chkUser=true;getBody("/server/chkuser.asp?name="+escape(b)+"&"+(new Date()).getTime(),"get",null,"if(err=='')eval(result);if("+a+"!=null && !parent.chkUser)$('u2').focus()",0,true)}}function regChkPass(a){var b=$("p2").value.trim();$("p2").value=b;if(b.length<6||b.length>16){if(a!=null)$("p2").focus();chkPassword=false;showErr("","密码长度不正确，应该为6~16位")}else{chkPassword=true;regChkPass2()}}function regChkPass2(a){var b=$("p3").value.trim();$("p3").value=b;var c=$("p2").value;if(b!=c){if(a!=null)$("p3").focus();chkPassword1=false;showErr("","两次输入密码不一致，请检查！")}else{chkPassword1=true;showErr("","")}}function regChkEmail(a){var b=$("e2").value.trim();$("e2").value=b;var c=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;if(!c.test(b)||b==""){if(a!=null)$("e2").focus();chkEmail=false;showErr("","您输入的Email不正确！")}else{getBody("/server/chkEmail.asp?email="+escape(b)+"&"+(new Date()).getTime(),"get",null,"if(err=='')eval(result);if("+a+"!=null && !parent.chkEmail)$('e2').focus()",0,true)}}function chkReg(){if(chkUser&&chkPassword&&chkPassword1&&chkEmail&&chkCode){var a=$("u2").value.trim();var b=$("p2").value.trim();var c=$("c2").value.trim();var d=$("e2").value.trim();if(!$("read").checked){reads(true);return false}var e="username="+escape(a)+"&psw="+escape(b)+"&CodeStr="+escape(c)+"&e_mail="+escape(d);var f="中国脱发网用户注册";showMsg("正在发送您的注册信息……",0,f);getBody("/server/reg.asp?"+(new Date()).getTime(),"post",e,"if(err!=''){parent.showMsg('严重错误，请报告给管理员，错误代码：'+err,5000,'"+f+"')}else{parent.execRegAndLogin(result,'"+f+"','注册')}",0,true)}else{if(!chkUser){regChkUser(true)}else if(!chkPassword){regChkPass(true)}else if(!chkPassword1){regChkPass2(true)}else if(!chkEmail){regChkEmail(true)}else if(!chkCode){loginChkCode("c2",true)}}return false}function execRegAndLogin(a,b,c){var d=5000;if(a.substr(0,14)=="checkLoginSuc:"){refresh=true;d=0;a=c+"成功，<span id='loginTime'>5</span>秒后返回"+c+"前页面。"+a.replace("checkLoginSuc:","")+"<br />选择进入：<a href='http://www."+webDomain+"'>[网站首页]</a>　<a href='http://bbs."+webDomain+"'>[论坛]</a>　<a href='http://shop."+webDomain+"'>[商城]</a>";this.re=function(){try{var t=parseInt($("loginTime").innerHTML);if(t>0)t--;$("loginTime").innerHTML=t;if(t==0)window.location=refreshURL}catch(e){clearInterval(f)}};var f=setInterval("re()",1000);showMsg(a,d,b,"<div onclick='closeFunction()'>返　回</div>")}else{closeFunction();showErr("",a)}}function loginChkUserName(a){var b=$("u1").value.trim();$("u1").value=b;if(b.length<1){if(a!=null)$("u1").focus();chkU=false;showErr("","请输入您的用户名！")}else{showErr('','');chkU=true};return chkU}function loginChkPass(a){var b=$("p1").value.trim();$("p1").value=b;if(b.length<6||b.length>16){if(a!=null)$("p1").focus();chkP=false;showErr("","密码长度不正确，应该为6~16位")}else{showErr('','');chkP=true};return chkP}function loginChkCode(c,a){chkCode=false;var b=$(c).value.trim();$("c1").value=$("c2").value=b;if(b==""){if(a!=null)$(c).focus();showErr("","请输入验证码！");chkCode=false}else{chkCode=true;showErr('','');getBody("/server/chkcode.asp?code="+b+"&"+(new Date()).getTime(),"get",null,"if(err=='')eval(result);if("+a+"!=null && !parent.chkCode)$('"+c+"').focus()",0,true)};return chkCode}function chkLogin(){if(chkU&&chkP){var a=$("u1").value.trim();var b=$("p1").value.trim();var c=$("c1").value.trim();$("errMsg").innerHTML="　";var d=$("CookieDate").value;var e="codestr="+escape(c)+"&username="+escape(a)+"&password="+escape(b)+"&CookieDate="+escape(d);var f="中国脱发网用户登陆";showMsg("正在发送您的登陆信息……",0,f);getBody("/server/login.asp?"+(new Date()).getTime(),"post",e,"if(err!=''){showMsg('严重错误，请报告给管理员，错误代码：'+err,5000,'"+f+"')}else{parent.execRegAndLogin(result,'"+f+"','登录')}",0,true)}else{if(!chkU){return loginChkUserName(true)&&loginChkPass(true)&&loginChkCode("c1",true)}else if(!chkP){return loginChkPass(true)&&loginChkCode("c1",true)}else if(!chkCode){return loginChkCode("c1",true)}}}function showErr(a,b){if(b!="")b="<div>"+b+"</div>";$("errMsg").innerHTML=b;if(a!=""){$(a).focus()};return false}function reads(a){if(!a)a=false;var b=630;var c=400;var l=(document.body.clientWidth-b)/2;var t=100;if(document.documentElement&&document.documentElement.scrollTop){t+=document.documentElement.scrollTop}else{t+=document.body.scrollTop}sAlert(b,c,l,t);getBodyLocal("/style/default/frame/regAgree.html","get",null,"if(err==''){parent.execShowReads(result,"+(b)+","+(c-2)+","+a+")}else{parent.showMsg('出现错误，错误代码:'+err+'<br />请将此错误报告给我们，非常感谢！',5000)}",0,true);window.onscroll=moveStart}function execShowReads(a,b,c,d){a=a.replace("{$mark}",d);$("alertFram").style.border="1px solid #AAAAAA";$("alertFram").innerHTML=a;$("functionBar").onmousedown=StartDrag;$("functionBar").onmousemove=Drag;$("functionBar").onmouseup=StopDrag;$("functionMain").style.cssText="margin:auto;width:"+b+"px;height:"+c+"px";$("functionLeft").style.width=(b-20)+"px";$("functionContent").style.width=(b-10)+"px";$("functionContent").style.height=(c-90)+"px"}function agree(a){closeFunction();$("read").checked=true;if(a){chkReg()}}