
	function fillFields(){
		document.form.FirstName.value = "John";
		document.form.LastName.value = "Doe";
		document.form.Email.value = "jdoe@gmail.com";
		document.form.Address1.value = "2027 Klamath River Dr";
		document.form.Address2.value = "";
		document.form.City.value = "Rancho Cordova";
		document.form.State.value = "CA";
		document.form.ZipCode.value = "95670";
		document.form.Howdidyoufindthissite.value = "Other";
		document.form.Other.value = "Saw it at 'a \"friends\" <b>house</b>";
		document.form.Comment.value = "<!-- this is it -->OK, here's a comment with a'; select * contacts; ]]]{{{||";
	}
		
function formSubmit(){
	if(validate(document.form)) {
		document.form.submit();
		return true;
	} else {
		return false;
	}
}

function validate(theForm){
    var errors = "";
		var required = new Array('ZipCode','FirstName','LastName');
    if(required.has('Phone')) if(theForm.phone.value != phoneVal) errors += checkPhone(theForm.phone.value);

    if(required.has('Email')) errors += checkEmail(theForm.Email.value);
		if(required.has('ZipCode')) errors += checkZip(theForm.ZipCode.value);
		if(required.has('FirstName')) errors += checkTextEmpty(theForm.FirstName.value, 'Enter your first name');
    if(required.has('LastName')) errors += checkTextEmpty(theForm.LastName.value, 'Enter your last name');

    if (errors != "") {
       alert('Please correct following error(s):\n'+errors);
       return false;
    }
	return true;
}

Array.prototype.indexOf = function(obj) {
  for (var i = 0; i < this.length; i++) {
    if (this[i] == obj)
      return i;
  }
  return -1;
}

Array.prototype.has = function(obj) {
  return this.indexOf(obj) >= 0;
} 
