function dopost() {
 qs="http://www.lighthouseassistedliving.com/portals/2/mail.asp?";
 if(! validate()) return;
 a="firstName;lastName;address;city;state;zip;country;dayPhone;fax;email;comments".split(";");
 for( n=0; n<a.length; n++ ) {
  e=document.getElementById(a[n]);
  if(e.type == 'checkbox' || e.type=='radio') {
   v=e.checked? e.value: '';
  } else {
   v=e.value;
  }
  if(v!='') qs+=a[n]+'='+encodeURIComponent(v)+'&';
 }
 alert("Thanks for taking the time to write us. Someone should reply soon.");
 document.location=qs;
}

function validate() {
  var retVal = true;
  errors = false;
  errorMessage = "The form was not submitted because of the following ";
  errorMessage += " error(s).\nPlease correct the error(s) and press ";
  errorMessage += "the Submit button.\n\n";
  // Check the required fields.
  if (isBlank(document.getElementById('firstName').value)) {
  	errors = true;
  	errorMessage += "Please Supply a First Name.\n";
  }
  if (isBlank(document.getElementById('lastName').value)) {
  	errors = true;
  	errorMessage += "Please Supply a Last Name.\n";
  }
  addressErrors = "";
  if (isBlank(document.getElementById('address').value)) {
  	errors = true;
  	errorMessage += "Please Supply an Address.\n";
  }
  if (isBlank(document.getElementById('city').value)) {
  	errors = true;
  	errorMessage += "Please Supply a City.\n";
  }
  if (isBlank(document.getElementById('state').value)) {
  	errors = true;
  	errorMessage += "Please Supply a State.\n";
  }
  if (isBlank(document.getElementById('zip').value)) {
  	errors = true;
  	errorMessage += "Please Supply a Zip Code.\n";
  }
  // Fail if any errors were found.
  if (errors) {
  	alert(errorMessage);
  	retVal = false;
  }
  return retVal;
}

function isBlank(s) {
retVal = true;
for (i = 0; i < s.length; i++ ) {
	c = s.charAt(i);
	if ((c != ' ') && (c != '\n') && (c != '\t')) {
		retVal = false;
		i = s.length;
	}
}
return retVal;
}
