﻿String.prototype.Trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, "");}

function newxmlhttp()
{
 var xmlhttp=null;  
 if (window.XMLHttpRequest){xmlhttp = new XMLHttpRequest();}  
 if (!xmlhttp&&window.ActiveXObject) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.5.0"); } catch(e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0"); } catch(e) { try { new ActiveXObject("Msxml2.XMLHTTP") } catch(e) { try{new ActiveXObject("Microsoft.XMLHTTP");}catch(e){} } } } }
 return xmlhttp;
}

function getHTML(URL) 
{
 var xmlhttp=newxmlhttp();
 xmlhttp.open("GET",URL, false);
 try{ xmlhttp.send(null); var result = xmlhttp.status; } catch(e) {return(false);}   
 if(result==200){ return(xmlhttp.responseText);}
 delete(xmlhttp)
}

function showloginbox()
{
var now=new Date();
var t=now.getFullYear().toString()+now.getMonth().toString()+now.getDay().toString()+now.getHours().toString()+now.getMinutes().toString()+now.getSeconds().toString()+now.getMilliseconds().toString();;
document.getElementById("LoginBox").innerHTML=getHTML("aloginbox.asp?t="+t);
}

function alogin()
{
var url=top.location.href;
var now=new Date();
var t=now.getFullYear().toString()+now.getMonth().toString()+now.getDay().toString()+now.getHours().toString()+now.getMinutes().toString()+now.getSeconds().toString()+now.getMilliseconds().toString();;

 var username=document.getElementById("ausername").value.Trim();
 if(username=="") { alert("用户名不能为空!"); return false; }
 var userpwd=document.getElementById("auserpwd").value.Trim();
 if(userpwd=="") { alert("密码不能为空!"); return false; }
 var ret=getHTML("alogin.asp?username="+username+"&userpwd="+userpwd+"&t="+t);
 if(ret=="1") top.location.href="user_main.asp"; //showloginbox();
 else {alert("用户名或密码错误!"); return false;}
}


function alogin2(username,userpwd,loginurl)
{
var now=new Date();
var t=now.getFullYear().toString()+now.getMonth().toString()+now.getDay().toString()+now.getHours().toString()+now.getMinutes().toString()+now.getSeconds().toString()+now.getMilliseconds().toString();;

username=username.Trim();
userpwd=userpwd.Trim();
 if(username=="") { alert("用户名不能为空!"); return false; }
 if(userpwd=="") { alert("密码不能为空!"); return false; }
 var ret=getHTML("alogin.asp?username="+username+"&userpwd="+userpwd+"&t="+t);
 if(ret=="1") top.location.href="user_main.asp";
 else {alert("用户名或密码错误!"); return false;}
}

function alogout()
{
var url=top.location.href;
var now=new Date();
var t=now.getFullYear().toString()+now.getMonth().toString()+now.getDay().toString()+now.getHours().toString()+now.getMinutes().toString()+now.getSeconds().toString()+now.getMilliseconds().toString();;

	getHTML("alogout.asp?t="+t);
	
	top.location.href=url; //	showloginbox();
}

