// contact.js

<!--
//Any fields that are left empty, or are not properly filled in, will be highlighted in red. //Fields that are filled in correctly will be properly formatted. 

function validate() {
  if(!document.getElementById) return;

  // get form variables
  var contactname = document.getElementById("contactname").value;
  //var lastname = document.getElementById("lastname").value;
  var email = document.getElementById("email").value;
  var phone = document.getElementById("phone").value;
  
  var validform = true;


/*  var address1 = document.getElementById("address1").value;
  var address2 = document.getElementById("address2").value;
  var city = document.getElementById("city").value;
  var state = document.getElementById("state").value;
  var zipcode = document.getElementById("zipcode").value;
  var fax = document.getElementById("fax").value; */
  
  var incorrect = new Array();
  var no = 0;
  var regExp = /[A-Za-z]{2,6}/;

 /* regExp = /[A-Za-z]{1,}/;
  if(regExp.test(firstname)) {
   	firstname = firstname.toUpperCase();
  } else {
   	incorrect[no] = "1";
  	 no++;
  	 firstname = "";
  }
*/

  regExp = /[A-Za-z]{3,}-?[A-Za-z]?/;
  if(regExp.test(contactname)) {
   	contactname = contactname.charAt(0).toUpperCase() + contactname.substring(1,contactname.length).toLowerCase();
  } else {
   	incorrect[no] = "1";
  	 no++;
   	contactname = "";
	validform = false;
  }


/*  regExp = /[A-Za-z]{3,}-?[A-Za-z]?/;
  if(regExp.test(lastname)) {
   	lastname = lastname.charAt(0).toUpperCase() + lastname.substring(1,lastname.length).toLowerCase();
  } else {
   	incorrect[no] = "2";
  	 no++;
   	lastname = "";
	validform = false;
  }*/

  if(email.length < 7) {

   	incorrect[no] = "2";
   	no++;
   	email = "";
	validform = false;
  }

  if((phone.length < 7) && (phone.length > 0)) {

   	incorrect[no] = "3";
   	no++;
   	phone = "";
	validform = false;
  }



/*  if(address1.length < 5) {
   	incorrect[no] = "4";
   	no++;
   	address1 = "";
  }

  if(address2.length < 3) {
   	incorrect[no] = "5";
   	no++;
   	address2 = "";
  }
  if(city.length < 3) {
   	incorrect[no] = "6";
   	no++;
   	city = "";
  }
  if(state.length < 5) {
   	incorrect[no] = "7";
   	no++;
   	state = "";
  }

  if(zipcode.length < 5) {

   	incorrect[no] = "8";
   	no++;
   	zipcode = "";
  }

  if(fax.length < 7) {

   	incorrect[no] = "8";
   	no++;
   	fax = "";
  }
*/

  for(i=1;i<4;i++) {
  		document.getElementById(i).style.color="#000000";
  }

  for(j=0;j<no;j++) {
  		document.getElementById(incorrect[j]).style.color="#FF0000";
  }

  if(no > 0) {
   	document.getElementById("errors").innerHTML = "<span class=\"error\">There was an error with your form submission. Please fill in the necessary fields.</span><br />";
  }

  document.getElementById("contactname").value = contactname;
/*  document.getElementById("lastname").value = lastname; */
  document.getElementById("email").value = email;
  document.getElementById("phone").value = phone;


  return validform;
/*  document.getElementById("address1").value = address1;
  document.getElementById("address2").value = address2;
  document.getElementById("city").value = city;
  document.getElementById("state").value = state;
  document.getElementById("zipcode").value = zipcode;
  document.getElementById("fax").value = fax;*/
}

