// JavaScript Document
var xmlhttp
function fn_loginscript(usrname)
{	
	if(document.getElementById("txtloginname").value == "")
	{
		alert("Enter Loginname");
		document.getElementById("txtloginname").txtloginname.focus();
		return false
	}
	if(document.getElementById("txtloginpassword").value == "")
	{
		alert("Enter Loginpassword");
		document.getElementById("txtloginpassword").txtloginpassword.focus();
		return false
	}
	
	str = document.getElementById("txtloginname").value;
	pswd = document.getElementById("txtloginpassword").value;
	
	xmlhttp=GetXmlHttpObject();
	
	if (xmlhttp==null)
	{
	  alert ("Your browser does not support XMLHTTP!");
	  return;
	}

		var url="Login.php";
		url=url+"?q="+str+"&pswd="+pswd;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChanged;	
	
	try
	{ 
	  xmlhttp.open("GET",url,true)
	
	}catch(e1)
	{	
		document.write("error1")
	}
	
	xmlhttp.send(null)

}



function stateChanged()
{	
	//document.getElementById("txtHint").innerHTML="";	
	if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete")
	{
			//alert(xmlhttp.responseText);
		if(xmlhttp.responseText != "Invalid Username / Password"  && xmlhttp.responseText != 'RemAdmin' && (xmlhttp.responseText.match(/table/i)))
		{			
				document.getElementById("divlogin").style.display = "none";
				document.getElementById("divlist").style.display = "block";
				document.getElementById("divlist").innerHTML =  xmlhttp.responseText;
		}
		else
		{	
			result = xmlhttp.responseText;
		    res = result.split("!");
			
			if(xmlhttp.responseText == 'RemAdmin')
			{
				document.form1.method="post";
				document.form1.action="Rem4edAddDomain.php";
				document.form1.submit();
			}
			else if(res[0]== 1)
			{
				document.form1.method="post";
				document.form1.action=res[1];
				document.form1.submit();
			}
			else
			{
				document.getElementById("divlogin").style.display = "block";
				document.getElementById("divlist").style.display = "none";
				document.getElementById("divmsg").innerHTML = xmlhttp.responseText;
			}
		}
	}
	else
	{
	  	document.getElementById("divmsg").innerHTML = '<font color="#006600"><strong>Checking...</strong></font>';
	}
}

function delayer(){
    window.location = "Rem4edBlockedUsers.php"
}

function GetXmlHttpObject()
{
	var objXMLHttp=null

	if(window.XMLHttpRequest)
	{
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  		objXMLHttp=new XMLHttpRequest()
  		//return new XMLHttpRequest();
  	}
	else if(window.ActiveXObject)
	{
  		// code for IE6, IE5
  		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		//return new ActiveXObject("Microsoft.XMLHTTP");
  	}

	return objXMLHttp;
}
