
function validate_bookingform() {
    validateError="";
    document.booking.action="onlinebooking.php";

    if (document.booking.firstname.value == "") {
        validateError = "You must fill in all the mandatory fields\n";
       }

	else if (document.booking.lastname.value == "") {
        validateError = "You must fill in all the mandatory fields \n";
       }

    else if (document.booking.primary_contact.value == "") {
        validateError = "You must fill in all the mandatory fields\n";
       }
    else if (document.booking.room_type.value == "") {
        validateError = "You must fill all the required fields \n";
       }
    else if (document.booking.numofrooms.value == "") {
        validateError = "You must fill in all the mandatory fields \n";
       }
    else if (document.booking.numofpersons.value == "") {
        validateError = "You must fill in all the mandatory fields \n";
       } 
	else if (document.booking.checkin.value == "") {
        validateError = "You must fill in all the mandatory fields \n";
       }
	else if (document.booking.checkout.value == "") {
        validateError = "You must fill in all the mandatory fields \n";
       }

  if (validateError!="") {
         alert(validateError);
         return false;
    }
  else
      {
       var pcontact = document.booking.primary_contact.value;
       if (pcontact.length < 6) {
			  alert("Invalid email address or phone number\nFor phone number please enter area code with phone number.");
			  return false;
	       }
    }

}

function validate_contactform() {
    validateError="";
    document.contact.action="contactus.php";

    if (document.contact.name.value == ""){
            validateError = "You must fill in all the mandatory fields marked with (*).";
       }
    else if (document.contact.email.value == "") {
        validateError = "You must fill in all the mandatory fields marked with (*).";
       }

	else if (document.contact.subject.value == "") {
        validateError = "You must fill in all the mandatory fields marked with (*).";
       }

    else if (document.contact.msg.value == "") {
        validateError = "You must fill in all the mandatory fields marked with (*).";
       }
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;
		       }
         }

      }

}
