function getXMLHttp()
{
	var xmlHttp
	try
	{
		//Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		//Internet Explorer
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				//alert()
				return false;
			}
		}
	}
	return xmlHttp;
}

function doEmailCheck(val)
{
  var xmlHttp = getXMLHttp();
  
  	var this_value = val;
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{
		 HandleResponse(xmlHttp.responseText);
		}
	}

  	xmlHttp.open("GET", "email_test.amp?email=" + this_value, true); 
	xmlHttp.send(null);
}

function HandleResponse(response)
{
	var response = response.toString();
	if (response.search('TAKEN') != -1)
	{
		alert('This email is associated with an existing account. Please login with the form on the right, or use the "Forgot Your Password" link to retrieve your password');

		try
		{
			document.getElementById('forgot_pass').style.display = 'block';
			document.getElementById('u').value=document.getElementById('email').value;
		}catch(e)
		{}

	}
}
