function validate() {

	// Function used to check form information entered onto shepherds.co.nz contact form
	// Created 15.01.07

	if (document.contactShepherds.formFirstName.value == "") {
		alert("Please enter a First Name");
		document.contactShepherds.formFirstName.focus();
	   return false
   }
	if (document.contactShepherds.formLastName.value == "") {
		alert("Please enter a Last Name");
		document.contactShepherds.formLastName.focus();
	   return false
   }			

	if (document.contactShepherds.formEmailAddress.value == "") {
		alert("Please enter an Email Address");
		document.contactShepherds.formEmailAddress.focus();
	   return false
   }

	if (document.contactShepherds.formContactDetails.value.length >= 500) {
		alert("You have exceeded the maximum length of 500 characters for the Contact Details.");
		document.contactShepherds.formContactDetails.select();
		return false;
	}

	email = document.forms[0].formEmailAddress.value;

	if (email == "" || email.length == 0) {
		alert("Please enter your email address");
		document.forms[0].formEmailAddress.select();
		return false;
   }

   else if (!check_email(email)) {
		alert("Please enter a valid email address");
		document.forms[0].formEmailAddress.select();
		return false;
   }

}

function check_email(e){
  ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
  for(i=0; i < e.length ;i++){
	  if(ok.indexOf(e.charAt(i))<0){
		  return (false);
		}	
	}	 

  if (document.images){
	  re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
	 re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

	 if (!e.match(re) && e.match(re_two)){
		 return (-1);		
		} 
	}
}