var xmlHttp

function login(email, password) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		  alert ("Your browser does not support our sign-in mechanism called AJAX. Please contact us for help.");
		  return;
	} 
	xmlHttp.onreadystatechange = stateChanged;
	var url = "ajax_login.php?";
		url += "email=" + email;
		url += "&password=" + password;
		url += "&rand=" + Math.random();
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
	
function stateChanged()  {
	if (xmlHttp.readyState==4) { 
		// Results passed back
		if (xmlHttp.responseText == 'false') {
			document.getElementById('submitbutton').innerHTML = '<input type="submit" name="submit" id="login-form-submit" value="Log In" />';
			Effect.Pulsate('loginmessage', {duration: 1.5, pulses: 3});
			document.getElementById('loginmessage').innerHTML = '<h1><img src="images/login_error.gif" /> Email address and/or password are incorrect. Please try again.</h1>';
		} else if (xmlHttp.responseText == 'true') {
			window.location = 'team_patches.php';
		}
	} else {
		// Logging in...
		document.getElementById('submitbutton').innerHTML = '<img src="images/login-ajax-loader.gif" alt="Signing In..." />';
	}
}
	
function GetXmlHttpObject() {
	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");
	  }
	}
	return xmlHttp;
}