function getCityAndStatesForZip(control)
{
	  xmlHttp=GetXmlHttpObject();
	  if (xmlHttp==null)
	  {
		return; 	
	  } 
	  var zipCode = control.value;
	  var url	=	"../common/zip/zipCodeDetector.asp?zip=" + zipCode;  
	  url		=	url	+	"&sid="+Math.random();
	  xmlHttp.onreadystatechange=stateChanged;
	  xmlHttp.open("GET",url,false);
	  xmlHttp.send(null);	
	  var result	=	xmlHttp.responseText;
	  var errorBoxID = control.id + "ErrorBox";
	  var errorBox = document.getElementById(errorBoxID);
	  if(result=="failure")
	  {			  
	  }
	  else
	  {
		populateCityAndState(result);
	  }
	  hideZipAjaxLoader();
	  return true;
}

function  showZipAjaxLoader()
{
	var zipAjaxLoader = document.getElementById("zipAjaxLoader");
	zipAjaxLoader.style.display="";	
}

function  hideZipAjaxLoader()
{
	var zipAjaxLoader = document.getElementById("zipAjaxLoader");
	zipAjaxLoader.style.display="none";	
}

function populateCityAndState(result)
{
	var state, city;
	state = getStringFromResponse(result,"state");
	city = getStringFromResponse(result,"city");
	var stateControl = document.getElementById("state");
	stateControl.value = state;
	var cityControl = document.getElementById("city");
	cityControl.value = city;
	//let's hide the error box for City field if it had any values:
	// This usually happens because the validation function will execute before the city field has been populated from the return value
	var cityErrorBox = document.getElementById("cityErrorBox");
	cityErrorBox.innerHTML = "";
	return;
}

function getStringFromResponse(response,wantedString) 
{ 
	var collection = response.split("&");
	for (var i=0;i<collection.length;i++) 
	{    
		var pair = collection[i].split("=");    
		if (pair[0] == wantedString) 
		{      
			return pair[1];    
		}  
	}   
}
