// Ajax

var xmlHttp;

function CheckUserLogin(username, password, form)
{
	var xmlHttp=null;
	
	try
	 {
		 // Firefox, Opera 8.0+, Safari
		 xmlHttp=new XMLHttpRequest();
	 }
	 
	catch (e)
	 {
		 //Internet Explorer
		 try
		  {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		 catch (e)
		  {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
	 }
	
	if (xmlHttp==null)
	{
		 alert ("Browser does not support HTTP Request");
		 return
	}

	var url = '/ask/includes/php/checkuserlogin.php?username=' + username + '&password=' + password; 
	
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")	
		{
			if(document.getElementById('ajax_response'))
			{
				if(xmlHttp.responseText == 'true') 
				{
					document.getElementById('ajax_login_button').innerHTML = '<img alt="Submitting question..." src="/graphics/loadingAnimation.gif">';
					form.submit();
				}
				else 
				{
					document.getElementById('ajax_response').innerHTML = '<span style="color:#FF0000;">Please check your account information and try again.</span>';
				}	
			}	
		}	
		else {}
	}
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}