

/* commented out because an error occurs when the form is submitted due to the objects (html id's) no longer being there


window.onload=set_start_field;


function set_start_field()
{
   document.getElementById('salutation').focus();
   select_ages();
   show_hide_hotel();
}

*/















function select_ages() /* makes the appropriate number of drop down menu for the ages visible */
{
  var nc = document.getElementById("qty_children").value*1;
	var IE = document.all?true:false;
	
  if( nc > 0)
  {
			if(IE)
			   document.getElementById("ch_ages").style.display="block"; /* show the division that the drop downs are within */

			else
			   document.getElementById("ch_ages").style.display="table-row"; /* show the division that the drop downs are within */

      for(var a=1 ; a < (nc+1) ; a++) /* show the appropriate number of drop downs */
			{
				if(IE)
	        document.getElementById("age_of_child"+a).style.display="block";

				else
	        document.getElementById("age_of_child"+a).style.display="table-row";
			}

      for(var a= (nc+1); a < 10 ; a++) /* hide the rest of the drop downs */
        document.getElementById("age_of_child"+a).style.display="none";
  }
  else
    document.getElementById("ch_ages").style.display="none";
}




function show_hide_hotel()
{
	var IE = document.all?true:false;

  if(document.getElementById("flight_or_package_f").checked)
  for(var c=1;c<5;c++)
    document.getElementById("not_flight_only"+c).style.display="none";

  if(document.getElementById("flight_or_package_p").checked || document.getElementById("flight_or_package_o").checked )

  for(var c=1;c<5;c++)
	{
	  if(IE)
    	document.getElementById("not_flight_only"+c).style.display="block";

	  else
    	document.getElementById("not_flight_only"+c).style.display="table-row";
	}
}






var error_flag=false;

function check_field(id)
{
    if(document.getElementById(id).value == "")
    {
      document.getElementById(id).style.background="red";
      error_flag=true;
      }
    else
      document.getElementById(id).style.background="white";
}

function check_field_em(id)
{
    var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;



    var em=document.getElementById(id).value;


     if(!re.test(em))
    {
      document.getElementById(id).style.background="red";
      error_flag=true;
      }
    else
      document.getElementById(id).style.background="white";

}


function check_field_textarea(id)
{
    var field_length=document.getElementById(id).value.length*1;
    var maxlength=document.getElementById(id).maxlength*1;

    if(field_length > maxlength)
    {
      alert('You have entered ' + (field_length-maxlength) + ' too many characters');
      document.getElementById(id).style.background="red";
      error_flag=true;
    }
    else
      document.getElementById(id).style.background="white";

}









function ValidForm(form)
{
  error_flag=false;

  check_field('name');
  check_field('qty_adults');
  check_field('earliest_departure');
  check_field('latest_departure');
  check_field('departure_airport');
  check_field('dest');
  check_field('duration');
  check_field('telephone');
  check_field_em('email');
  check_field_textarea('notes');
  check_field_textarea('other_offers');



  if(error_flag==true)
  {
    alert("Please complete all the fields that are highlighted in red");
    error_flag=false;
  	return false;
	}

	return true;

}

