﻿String.prototype.trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g,""); 
} 
function chkLogin()
{
	if(document.frmLogin.username.value.trim()=='')
	{
		alert("用户名不能为空！");
		document.frmLogin.username.focus();
		return false;
	}
	if(document.frmLogin.password.value.trim()=='')
	{
		alert("密码不能为空！");
		document.frmLogin.password.focus();
		return false;
	}
	document.frmLogin.submit();
}

var xmlhttp,alerted,xmlhttplogin,xmlhttpmemologin;
function init()
{
	try
	{
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	}
	catch(e)
	{
		try
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch(E)
		{
			xmlhttp = new XMLHttpRequest();
		}
	}
	if(!xmlhttp && !alerted)
	{
		try
		{
			xmlhttp = new XMLHttpRequest();
		}
		catch(e)
		{
			alert("你的浏览器不支持XMLHttpRequest对象，无法使用此功能！");
		}
	}
}

function initlogin()
{
	try
	{
		xmlhttplogin=new ActiveXObject("Msxml2.XMLHTTP")
	}
	catch(e)
	{
		try
		{
			xmlhttplogin=new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch(E)
		{
			xmlhttplogin = new XMLHttpRequest();
		}
	}
	if(!xmlhttplogin && !alerted)
	{
		try
		{
			xmlhttplogin = new XMLHttpRequest();
		}
		catch(e)
		{
			alert("你的浏览器不支持XMLHttpRequest对象，无法使用此功能！");
		}
	}
}

function initmemologin()
{
	try
	{
		xmlhttpmemologin=new ActiveXObject("Msxml2.XMLHTTP")
	}
	catch(e)
	{
		try
		{
			xmlhttpmemologin=new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch(E)
		{
			xmlhttpmemologin = new XMLHttpRequest();
		}
	}
	if(!xmlhttpmemologin && !alerted)
	{
		try
		{
			xmlhttpmemologin = new XMLHttpRequest();
		}
		catch(e)
		{
			alert("你的浏览器不支持XMLHttpRequest对象，无法使用此功能！");
		}
	}
}



function getlogin()
{
	initlogin();
	if(xmlhttplogin)
	{ 
		//document.getElementById("divlogin").innerHTML = "login...";
		xmlhttplogin.Open("Get","Whetherlogin.asp?para=" + Math.random()*2147483647,true);
		xmlhttplogin.onreadystatechange=RSchange;  
		xmlhttplogin.send();
	}
}


function RSchange() 
{
	if (xmlhttplogin.readyState==4)
	{
		if(xmlhttplogin.status==200)
		{
			if(xmlhttplogin.responseText.trim()=="true")
			{
				document.getElementById("divlogin").style.display="none";
				document.getElementById("divmanage").style.display='block';
			}else{
				document.getElementById("divlogin").style.display="block";
				document.getElementById("divmanage").style.display='none';	
			}
			
		}else{
			document.getElementById("divlogin").style.display="block";
			document.getElementById("divmanage").style.display='none';	
		}
	}else{
		document.getElementById("divlogin").style.display="block";
		document.getElementById("divmanage").style.display='none';	
	}
}


function getmemologin()
{
	initmemologin();
	if(xmlhttpmemologin)
	{ 
		//document.getElementById("divlogin").innerHTML = "login...";
		xmlhttpmemologin.Open("Get","Whetherlogin.asp?para=" + Math.random()*2147483647,true);
		xmlhttpmemologin.onreadystatechange=RSchangememo;  
		xmlhttpmemologin.send();
	}
}


function RSchangememo() 
{
	if (xmlhttpmemologin.readyState==4)
	{
		if(xmlhttpmemologin.status==200)
		{
			if(xmlhttpmemologin.responseText.trim()=="true")
			{
				document.getElementById("memologinid").innerHTML="&nbsp;";
			}
		}
	}
}


function getinquiry()
{
	init();
	if(xmlhttp)
	{ 
		xmlhttp.Open("Get","Whetherinquiry.asp?para=" + Math.random()*2147483647,true);
		xmlhttp.onreadystatechange=Cschange;  
		xmlhttp.send();
	}
}


function Cschange() 
{
	if (xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			if(xmlhttp.responseText.trim()=="true")
			{
				document.getElementById("content").style.display="block";
			}else document.getElementById("content").style.display='none';
			
		}else document.getElementById("content").style.display='none';
	}else document.getElementById("content").style.display='none';
}


