var zipform = "";
var xmlHttp = createXmlHttpRequestObject(); 

function createXmlHttpRequestObject() 
{	
 var xmlHttp;
 if(window.ActiveXObject){
  try{xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}
  catch (e) {xmlHttp = false;}
 }
 else{
  try {xmlHttp = new XMLHttpRequest();}
  catch (e){xmlHttp = false;}
 }
 if (!xmlHttp)
  alert("Can't use Ajax. You have to allow JavaScript");
 else 
  return xmlHttp;
}

function GetZip(zipname, zform)
{
 if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
  zipform = zform;
  xmlHttp.open("GET", "zipchecker.php?zip="+zipname, true);  
  xmlHttp.onreadystatechange = handleServerResponse;
  xmlHttp.send(null);
 }
}

function handleServerResponse() 
{
 if (xmlHttp.readyState == 4) {
  if (xmlHttp.status == 200) {
   if (xmlHttp.responseText == 1)
   {
   		document.forms[zipform].submit();
   }
   else
    alert("Incorrect ZIP code");
  } 
  else{alert("There was a problem accessing the server: " + xmlHttp.statusText);}
 }
}


