function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function verifyForm(thForm){
	var msg = "";
	if(trim(thForm.firstname.value) == '')
		msg += "Please enter your first name.\n";
	if(trim(thForm.lastname.value) == '')
		msg += "Please enter your last name.\n";
	if(trim(thForm.email.value) == '')
		msg += "Please enter a valid email address.\n";
	if(trim(thForm.phone.value) == '')
		msg += "Please enter your telephone number.";

	// If no error messages were added, process form
	if(msg==""){
		return true;
	}else{
		alert(msg);
		return false;
	}//if
}//verifyForm

function findLocation(){
	var zipcode = document.getElementById('zipCodeSearch').value;

	// Jquery was not working. So, do it the old fashioned way!!
	// Set up the request
  var xmlhttp; //declare the variable to hold the object.
  var browser = navigator.appName; //find the browser name
  if(browser == "Microsoft Internet Explorer") {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }else{
    xmlhttp = new XMLHttpRequest();
  }//if
  xmlhttp.open('POST', 'high_quality_custom_hearing_aids/zip_code_lookup.php', true);

  // The callback function
  xmlhttp.onreadystatechange = function() {
    try{if (xmlhttp.readyState == 4) { // Finished loading
      if (xmlhttp.status == 200){ // Completeed Successfully
         var response_stat = xmlhttp.responseText;
         var locatorBox = document.getElementById('locatorBox');
         var locatorResults = document.getElementById('locatorResults');
         locatorBox.style.display = "block";
         locatorResults.innerHTML = response_stat;
      }//if
    }}catch(e){}//try
  }//function

  // Send the POST request
  xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  xmlhttp.send('zip='+zipcode);
}//findLocation

function closeLocatorBox(){
	document.getElementById('locatorBox').style.display = "none";
	document.getElementById('locatorResults').innerHTML = "";
}//closeLocatorBox