/* Contact Form Validation */

function checkFormat(theName, theValue) {
	var chara;
	var email="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.@-_" ;

	if(theName=="email") {
      chara=email;
	}
	else{return false;}

	for(var i=0; i<theValue.length; i++) {
      if(chara.indexOf(theValue.substring(i,i+1))==-1) {
        return true;
	  }
	}
	
	return false;
}


function checkEmail()
         {
		if ((document.contact_us.email.value.indexOf("@") != -1) && 
			(document.contact_us.email.value.indexOf("@") < document.contact_us.email.value.lastIndexOf("."))
                     && (checkFormat('email', document.contact_us.email.value) != -1)){ } else
		{
                Alerttag += "- Email \n";
		}
	}

function newcheck() {
	  if(document.contact_us.name.value =="") {
                Alerttag += "- Name \n";
	  }
      checkEmail();
	  if(document.contact_us.enquiry.value =="") {
        Alerttag += "- Enquiry \n";
	  }

}

function lastCheck () {
	Alerttag = "";
	newcheck();
    if(Alerttag == "") {
	  if (confirm("Do you want to send this information?")){
	  document.contact_us.submit();}
	}
    else {
	  Alerttag2 = "Please make sure that the required fields are filled.\n\n";
	  Alerttag2 += Alerttag;
	  alert (Alerttag2); 
	  return false ;
    }
}