﻿// JScript 文件
document.writeln("  <div style=\"position: absolute; top: 50px; left: 280px; z-index: 20; display: none;\"");
document.writeln("        id=\"LoginFormDiv\">");
document.writeln(" <table width=\"300\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"box06\">");
document.writeln("            <form id=\"FormDivLogin\" name=\"FormDivLogin\" onsubmit=\"return LoginSumbit(FormDivLogin);\">");
document.writeln("   <tr>");
document.writeln("     <td><table width=\"300\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFFF\" class=\"box07\">");
document.writeln("       <tr align=\"left\" valign=\"bottom\">");
document.writeln("        <td height=\"25\" >&nbsp;<a href=\"register.htm\" target=\"_blank\" class=\"love_04\">立即注册&gt;&gt;</a></td>");
document.writeln("      <td height=\"25\" align=\"right\"><a href=\"javascript:ShowLoginDivNone();\"><img src=\"http://blog.mz99.com/mzlove/images/50.gif\" width=\"15\" height=\"15\" border=\"0\"></a>&nbsp;</td>");
document.writeln("       </tr>");
document.writeln("      <tr   >");
document.writeln("        <td height=\"14\" colspan=\"2\"background=\"http://blog.mz99.com/mzlove/images/08.gif\"></td>");
document.writeln("      </tr>");
document.writeln("      <tr>");
document.writeln("        <td width=\"230\" height=\"50\" align=\"center\"><table width=\"220\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
document.writeln("           <tr align=\"left\" valign=\"middle\">");
document.writeln("             <td width=\"50\" height=\"25\" class=\"style2\">用户名：</td>");
document.writeln("             <td width=\"61\"><input name=\"txtUsername\" type=\"text\" class=\"box04\" size=\"8\" onkeydown=\"if (event.keyCode==13) FormDivLogin.onsubmit()\"></td>");
document.writeln("             <td width=\"37\" class=\"style2\">密码：</td>");
document.writeln("             <td width=\"52\"><input name=\"txtPassword\" type=\"password\" class=\"box04\" size=\"8\" onkeydown=\"if (event.keyCode==13) FormDivLogin.onsubmit()\"></td>");
document.writeln("            </tr>");
document.writeln("           <tr align=\"left\" valign=\"middle\">");
document.writeln("              <td height=\"25\" class=\"style2\">验证码：</td>");
document.writeln("              <td><input name=\"txtValidate\" type=\"text\" class=\"box04\" size=\"8\" onkeydown=\"if (event.keyCode==13)FormDivLogin.onsubmit()\"></td>");
document.writeln("              <td colspan=\"2\">&nbsp;&nbsp;<img id=\"valideCodeImg1\" alt=\"看不清 请点此!\" src=\"#\" onclick=\"javascript:this.src=\'/validCode.aspx?\'+Math.random();\" \/></td>");
document.writeln("            </tr>");
document.writeln("         </table></td>");
document.writeln("         <td width=\"70\" align=\"center\"><a href=\"#\" onclick=\"FormDivLogin.onsubmit()\"><img src=\"http://blog.mz99.com/mzlove/images/09.gif\" width=\"52\" height=\"46\" border=\"0\"></a></td>");
document.writeln("      </tr>");
document.writeln("    </table></td>");
document.writeln("   </tr>");
document.writeln("            <\/form>");
document.writeln(" </table>");
document.writeln("    <\/div>")




  //登录提交Ajax----------------------------------------------------------------
        function LoginSumbit(FormIndexLogin)
        {
            var username = FormIndexLogin.txtUsername.value;
            var password = FormIndexLogin.txtPassword.value;
            var validcode = FormIndexLogin.txtValidate.value;
            //var url = "/CheckLogin.aspx?username="+username+"&password="+password+"&validcode="+validcode;           
            var url = "/mzlove/login.aspx?username="+username+"&password="+password+"&validcode="+validcode;
    
     
	        if (window.XMLHttpRequest) {
		        req = new XMLHttpRequest();
		        req.onreadystatechange = LoginSumbitprocessChechLogin;
		        req.open("GET",url , true);
		        req.send(null);
	        } else if (window.ActiveXObject) {
		        req = new ActiveXObject("Microsoft.XMLHTTP");
		        if (req) {
			        req.onreadystatechange = LoginSumbitprocessChechLogin;
			        req.open("GET", url, true);
			        req.send();
		        }
	        }
        	
	        return false;
        }

        function  LoginSumbitprocessChechLogin() {
	        if (req.readyState == 4) {
		        if (req.status == 200) {
        			
        			 var requestname = req.responseText.substring(0,2);
			        if(requestname == "正确"){
			            var UserLoveInfoStr = req.responseText.substring(2,req.responseText.length);
                        setCookie("UserLoginInfoStr",UserLoveInfoStr);
			     
			               alert('登录成功！');	  
                           window.location.reload();
        				
			        }else{
			           alert(req.responseText);
			           if(req.responseText == "验证码不对或失效，请您填写正确的验证码！")
			           {
			              if(document.getElementById("LoginFormDiv").style.display ==  "none")
			              {}
			              else
			                 document.getElementById("valideCodeImg1").src = "/validCode.aspx?"+Math.random();
			           }
			           if(req.responseText == "此用户已经是名智通行用户，但还没有注册空间！")
			           {
			              window.location.href = "http://blog.mz99.com/reghave.aspx?username="+document.getElementById("txtUsername").value;
			           }
        			   
			        }
		        } else {
			        alert("服务暂时不能使用！");	
		        }
	        }
        }
       //隐藏显示LOGIN层
        function ShowLoginDivNone()
        {       
           
           document.getElementById("LoginFormDiv").style.display = "none";
           return ;
        }
        
        
       //显示隐藏LOGIN层
        function ShowLoginDiv()
        {
          document.getElementById("valideCodeImg1").src = "/validCode.aspx?"+Math.random();
           var loginInfo = getCookie("UserLoginInfoStr");    
          if((guestUser !="") && (loginInfo !=""))
          {
              alert('已经登录!');
              return;
          }
          
          
           document.getElementById("LoginFormDiv").style.display = "block";
           return ;
        }