// JavaScript Document

function validateForm(theForm)


{

if (theForm.Arrival_Month.value == "0")
  {
	  
    alert("You need to indicate the arrival month.");
    theForm.Arrival_Month.focus();
    return (false);
  }
  
if (theForm.Arrival_Day.value == "0")
  {
	  
    alert("You need to indicate the arrival day.");
    theForm.Arrival_Day.focus();
    return (false);
  }
  
if (theForm.Departure_Month.value == "0")
  {
	  
    alert("You need to indicate the departure month.");
    theForm.Departure_Month.focus();
    return (false);
  }
  
if (theForm.Departure_Day.value == "0")
  {
	  
    alert("You need to indicate the departure day.");
    theForm.Departure_Day.focus();
    return (false);
  }
  
  if (theForm.Arrival_Month.value == theForm.Departure_Month.value)
 { if (parseInt(theForm.Arrival_Day.value) >= parseInt(theForm.Departure_Day.value))
 
  {
    alert("Arrival day should be before the departure day.");
    theForm.Arrival_Day.focus();
    return (false);
  }

 }


  if (theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email.value.length < 6)
  {
    alert("Please enter a valid email address in the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@.";
  var checkStr = theForm.Email.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter a valid email address in the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }
  
var checkOK = "0123456789";
  var checkStr = theForm.Budget.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digits in the \"Budget\" field.");
    theForm.Budget.focus();
    return (false);
  }

  
if (!theForm.Budget.value == "" && theForm.Budget.value<50)
 
  {
    alert("Minimum price is 50 US$ per night.");
    theForm.Budget.focus();
    return (false);
  }




  return (true);
}
