var myAJAXResponse;

function getXMLHTTPRequest()
{
	var req = false;
	try
	{
		req = new XMLHttpRequest(); 
	}
	catch(err1)
	{
		try 
		{
	req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(err2)
		{
			try
			{
	req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(err3)
			{
				req = false;
			}
		}
	}
	return req;
}

var myRequest = getXMLHTTPRequest();

function callAjax(url) {
	var myRand = + new Date().getTime();
	myRequest.open("GET", url+"&rand=" + myRand, true);
	myRequest.onreadystatechange = responseAjax;
	myRequest.send(null);
}


function responseAjax()
{
	document.getElementById('loginMessage').innerHTML="";

	if (myRequest.readyState == 4)
	{
		if (myRequest.status == 200)
		{
			document.location.href = 'manage_account.php';
		}
		else if (myRequest.status == 412)
		{
		    if (myRequest.responseText == "This is not a valid username") {
				document.getElementById('loginMessage').innerHTML=myRequest.responseText;
			}
			if (myRequest.responseText == "This is not the password we have on file") {
				document.getElementById('loginMessage').innerHTML=myRequest.responseText;
			}
		}
	}
}


