// JavaScript Document
function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) 
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} 
} 

 function validate() {
    validateError="";
    document.contact.action="sendemail.php";

    if (document.contact.name.value == ""){
            validateError += "You must fill in your name\n";
       }
	if (document.contact.subject.value == "") {
	        validateError += "You must fill in enquiry subject\n";
	       }
    if (document.contact.email.value == "") {
        validateError += "You must fill in your valid email\n";
       }
     if (document.contact.message.value == "") {
        validateError += "You must fill in your message\n";
       }
  

  if (validateError!="") {
         alert(validateError);
         return false;
    }
  else
      {
       var email = document.contact.email.value;
       emaillen = email.length;
	       if (email.length < 6) {
			  alert("Invalid email address! \n Please enter a valid email address.");
			  return false;
	       }

	       else {
	         var passed1Counter = 0;
	         var passed2Counter = 0;

		       for (i = 0; i < email.length; i++) {
				 var character = email.charAt(i);
					switch(character) {
						case '@':
							 passed1Counter++;
						     break;
						case '.':
	                         passed2Counter++;
						     break;
					}
		       }

		       if (passed1Counter != 1 || passed2Counter == 0) {
	               alert("Invalid email address! \n Please enter a valid email address.");
	               return false;
		       }
         }

      }

}
