
// JavaScript Document
		function ajax_check(url){
			var xmlHttp = false;
			if (window.ActiveXObject) {
				xmlHttp = new ActiveXObject("MsXml2.XmlHttp");
			}else{
				xmlHttp = new XMLHttpRequest();
			}
			var url=url;
			xmlHttp.open("GET", url, false);
			xmlHttp.setRequestHeader("If-Modified-Since","0");
			//xmlHttp.onreadystatechange = callback;
			xmlHttp.send(null);
			if (xmlHttp.readyState == 4){
			// only if "OK"
				if(xmlHttp.status == 200) {
					var text = xmlHttp.responseText;
					return text; 
				}else{
				  //alert("你的網有延遲,請刷新此頁面\n" +  req.statusText);
					return "-1";
				}
			}
			
		}
		
		

	   function CheckForm(myurl){
		  
			if(document.getElementById("username").value!=""&&document.getElementById("password").value!=""){
				var texta=ajax_check("ajax_login.php?username="+document.getElementById("username").value+"&password="+document.getElementById("password").value);
				if(texta!="-1"){
					window.location=myurl;
					document.getElementById("loginState").innerHTML=texta;
									

				}else{
					document.getElementById("login_tip").innerHTML="<font color=green>网络延迟过长,请刷新此页面重新登录!</font>";
				}
			}else{
				document.getElementById("username").focus();
				document.getElementById("login_tip").innerHTML="<font color=green>請輸入用戶名和密碼登錄，如果沒有用戶名請聯繫客服索取﹗</font>";
				return false;
			}
    				  
	   }

	   
	function clickButton(myurl) 
    {     
       if (event.keyCode == 13) 
       { 

        SendSubmit(myurl);
       }
     }

   function SendSubmit(myurl)
   {
			document.getElementById("login_tip").innerHTML="<font color=green>正在登錄中請稍等...</font>";
			setTimeout("CheckForm('"+myurl+"');",2000); 
			
	 }
	  
	  function loginOut(){				
			  if(confirm("你真的要退出登錄嗎？")){	
				  var texta=ajax_check("ajax_login.php?loginout=loginout");
				  if(texta!="-1"){
							document.getElementById("loginState").innerHTML=texta;
							window.location="index.php";
				}else{
					document.getElementById("login_tip").innerHTML='<font color=green>網路延遲過長,請刷新此頁面重新登錄!</font>';
				}
			  }
	  }

	   function checkname(){				
			  
			  var name=document.getElementById("name").value;	
			  if(name!="")
		   {
				  var texta=ajax_check("ajax_login.php?name="+name);
				  if(texta!="-1"){
							document.getElementById("checkstate").innerHTML=texta;
				}else{
					document.getElementById("checkstate").innerHTML='<font color=green>網路延遲過長,請刷新此頁面重新登錄!</font>';
				}
		   }
			  
	  }


