function isEmailAddr (s){ 
	var rv = false
	if ((s == null) || (s.length == 0)) 
       	rv = false;
 	 else {
		var reEmail =/([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		//reEmail = /.+\@.+\..+$/
		
		rv = reEmail.test(s)
    }
	if(rv){
		return rv
	}else{
		return false
	}
}

function IsNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function isValidTime(value) {
   var hasMeridian = false;
   var re = /^\d{1,2}[:]\d{2}([:]\d{2})?( [aApP][mM]?)?$/;
   if (!re.test(value)) { return false; }
   if (value.toLowerCase().indexOf("p") != -1) { hasMeridian = true; }
   if (value.toLowerCase().indexOf("a") != -1) { hasMeridian = true; }
   var values = value.split(":");
   if ( (parseFloat(values[0]) < 0) || (parseFloat(values[0]) > 23) ) { return false; }
   if (hasMeridian) {
      if ( (parseFloat(values[0]) < 1) || (parseFloat(values[0]) > 12) ) { return false; }
   }
   if ( (parseFloat(values[1]) < 0) || (parseFloat(values[1]) > 59) ) { return false; }
   if (values.length > 2) {
      if ( (parseFloat(values[2]) < 0) || (parseFloat(values[2]) > 59) ) { return false; }
   }
   return true;
}

function validate_functions(theForm)
{
	if (theForm.name.value == ""){
    	alert("Please enter your name.");
    	theForm.name.focus();
    	return (false);
  	}
	if (theForm.phone.value == "" || !IsNumeric(theForm.phone.value)){
		alert("Please enter your Phone Number");
		theForm.phone.focus();
		return (false);
  	}
	if (theForm.numPeople.value == "" || theForm.numPeople.value == 0 || !IsNumeric(theForm.numPeople.value)){
		alert("Please enter the correct number of your people");
		theForm.numPeople.focus();
		theForm.numPeople.value = "";
		return (false);
  	}
	if (theForm.DOF_Day.value == ""){
    	alert("Please enter the day of your birth");
    	theForm.DOF_Day.focus();
    	return (false);
  	}
	if (theForm.DOF_Month.value == "" ){
		alert("Please enter the month of your birth");
		theForm.DOF_Month.focus();
		return (false);
  	}
	if (theForm.DOF_Year.value == ""){
    	alert("Please enter the year of your birth.");
    	theForm.DOF_Year.focus();
    	return (false);
  	}
	if (theForm.time.value == "" || !IsValidTime(theForm.time.value)){
		alert("Please enter a valid time of your booking. eg. 12:25 am");
		theForm.time.focus();
		return (false);
  	}
	if (theForm.additional.value == ""){
		alert("Please enter your additional information");
		theForm.additional.focus();
		return (false);
  	}
	return true;
}
function validate_VIP(theForm)
{
	if (theForm.Name.value == ""){
    	alert("Please enter your name.");
    	theForm.Name.focus();
    	return (false);
  	}
	if (!isEmailAddr(theForm.Email.value)){
    	alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    	theForm.Email.focus();
    	return (false);
 	}
	if (theForm.Address.value == ""){
    	alert("Please enter the postal address.");
    	theForm.Address.focus();
    	return (false);
  	}
	if (theForm.DOB_Day.value == ""){
    	alert("Please enter the day of your birth.");
    	theForm.Name.focus();
    	return (false);
  	}
	if (theForm.DOB_Month.value == ""){
    	alert("Please enter the month of your birth.");
    	theForm.Name.focus();
    	return (false);
  	}
	if (theForm.DOB_Year.value == ""){
    	alert("Please enter the year of your birth.");
    	theForm.Name.focus();
    	return (false);
  	}
	return true;
}
	