var http;
var url;

function handleHttpResponse_validzip() 
{ 
	
	if (http.readyState == 4) 
	{	
		isWorking = false;
		
		if (http.responseText.indexOf('invalid contents') == -1) 
  		{
			//alert(http.responseText);
			var xmlDocument = http.responseXML;
			document.getElementById("azipcode").value = '';
			var msg = xmlDocument.getElementsByTagName('msg').item(0).firstChild.data;
			var valid = xmlDocument.getElementsByTagName('validdata').item(0).firstChild.data;
			//alert(valid+"->"+msg);
			if(msg != '')
				alert(msg);
			if(valid == '')
				valid = '---Any---';
			document.getElementById("azipcode").value = valid;
			isWorking = false;
  		}
	}
}

function getValidZip(val)
{
	if(val == '--Any--')
		val = '';
	var zipcode = Trim_validate(val);
		url = site_ajax_url+"getvalidzip.php?zipcode="+zipcode;
		
		var isWorking = false;
  		
		if (!isWorking)
    	{
    		if (window.XMLHttpRequest)
      		{
      			http=new XMLHttpRequest()
	      		http.open("GET",url, true);
    		  	http.onreadystatechange=handleHttpResponse_validzip
    		  	http.send(null)
      		}
	    	// code for IE
    		else if (window.ActiveXObject)
      		{
      			http=new ActiveXObject("Microsoft.XMLHTTP")
	        	if (http)
    	    	{
        			http.open("GET",url, true);
        			http.onreadystatechange=handleHttpResponse_validzip
        			http.send()
        		}
	      	}
	  //	}
	}
}


function myXMLHttpRequest() 
{
	  var xmlhttplocal;
	  try {
    		//xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
			xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
	   } 
	   catch (e) 
	   {
			try 
			{
				xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
			} 
			catch (E) 
			{
			    xmlhttplocal=false;
			}
		}

		if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') 
		{
			try 
			{
				var xmlhttplocal = new XMLHttpRequest();
			} 
			catch (e) 
			{
				var xmlhttplocal=false;
				alert('couldn\'t create xmlhttp object');
			}
		}
	return(xmlhttplocal);
}

function AllowOnlyzipsNumeric(events)
{  
	var unicodes = events.charCode? events.charCode :events.keyCode;
	if(unicodes > 47 && unicodes < 58)
	   return true;
	else if(unicodes == '44' || unicodes == '9')
		return true;
	else
		return false;
}

function AllowPrice(events)
{  
	var unicodes = events.charCode? events.charCode :events.keyCode;
	if(unicodes > 47 && unicodes < 58)
	   return true;
	if(unicodes == 8 || unicodes == 9)  
	   return true;
	else
		return false;
}
