// JavaScript Document
var receiveReq;
var status;

function getXmlHttpRequestObject() 
	{	
		if (window.XMLHttpRequest){	
			return new XMLHttpRequest();	
			}
		else if(window.ActiveXObject){	
		 	return new ActiveXObject("Microsoft.XMLHTTP");	
		 	}
	 	else
	 	  {		
		alert("Your browser doesn't support the XmlHttpRequest object. Better upgrade to Firefox.");
	 	  	}
	}

function check(){}

function forgotpassword()
{
	var un=document.getElementById("funame").value;
	var fe=document.getElementById("ferror");
	if(un.length<6)
	{
		fe.innerHTML="Invalid username";
		return;
	}
	else
	{
		var ld=document.getElementById("loading");
		ld.style.display="block";
		var ft=document.getElementById("ftype").value;
		url="forgot.php?un="+un+"&ft="+ft;
		var xmlHttp = getXmlHttpRequestObject();
		receiveReq=xmlHttp;
		xmlHttp.onreadystatechange = check;
		receiveReq.open("POST",url,false);
		xmlHttp.send(null);
		if(receiveReq.readyState == 4) 
		{
			fe.innerHTML=receiveReq.responseText;
			ld.style.display="none";
		}
		else
		{
			alert("Couldn't connect to server this time.");
			ld.style.display="none";
		}
	}
}

function authcheckun()
{
	var un=document.getElementById("username").value;
	var pw=document.getElementById("password").value;
	var fe=document.getElementById("errorf");
	if(un.length<6 || pw.length<6)
	{
		fe.style.display="block";
		return false;
	}
	else
	{
		var ld=document.getElementById("loading");
		ld.style.display="block";
		var ut=document.getElementById("utype");
		url="riaindia/authcheck.php?un="+un+"&pw="+pw+"&ut="+ut.value;
		var xmlHttp = getXmlHttpRequestObject();
		receiveReq=xmlHttp;
		xmlHttp.onreadystatechange = check;
		receiveReq.open("POST",url,false);
		xmlHttp.send(null);
		if(receiveReq.readyState == 4) 
		{
			if(receiveReq.responseText=="false")
			{
				fe.style.display="block";
				ld.style.display="none";
				return false;
			}
			else if(receiveReq.responseText=="true")
			{
				ld.style.display="none";
				return true;
			}
		}
		else
		{
			alert("Couldn't connect to server this time.");
			ld.style.display="none";
			return false;
		}
	}
}