var xmlHttp;

function GetXmlHttpObject()
{ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
} //function

function SendRequest(pUrl)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 

	xmlHttp.onreadystatechange = stateChanged ;
	xmlHttp.open("GET",pUrl,true);
	xmlHttp.send(null);
}

function SendRequestWithResponse(pUrl)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 

	xmlHttp.onreadystatechange = stateChangedWithResponse ;
	xmlHttp.open("GET",pUrl,true);
	xmlHttp.send(null);
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById("Result").innerHTML = "";//xmlHttp.responseText ;
	} 
} //function

function stateChangedWithResponse() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var lstrResponse = new String(xmlHttp.responseText);
		var larrValues = lstrResponse.split("|");
		document.getElementById("cityEntry").value = String(larrValues[0]);
		document.getElementById("stateEntry").value = String(larrValues[1]);
		if (("" == document.getElementById("cityEntry").value) && ("US" == document.getElementById("countryEntry").value))
		{
			alert("Invalid zip code.");
			document.getElementById("zipEntry").value = "";
		}
		//document.getElementById("Result").innerHTML = lstrResponse;
		document.getElementById("spnWarning").innerHTML = "";
//		document.getElementById("emailEntry").focus();
	} 
} //function


function EmailChangedWithResponse() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var lstrResponse = new String(xmlHttp.responseText);
		document.getElementById("emailWarning").innerHTML = lstrResponse;
				document.getElementById("btnSubmit").style.visibility = "visible";	
				document.getElementById("divCheckingEmail").style.display = "none";	
				
		if(lstrResponse.indexOf("invalidx.gif") > 0)
		{
			document.getElementById("emailFlagValidation").value = 0;

		}
		else
		{
			document.getElementById("emailFlagValidation").value = 1;
		}
	} 
} //function


function EmailSendRequestWithResponse(pUrl)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 

	xmlHttp.onreadystatechange = EmailChangedWithResponse ;
	xmlHttp.open("GET",pUrl,true);
	xmlHttp.send(null);
}
