// JavaScript Document

function populateStates(form){
    var objFormField;
    var country;
	var enter_state = document.getElementById("enter_state");
    objFormField = form.state;
    country = form.country.options[form.country.selectedIndex].value;
    objFormField.length=0;
    if ( country < 0 || country=="" || jStates[country]==null || jStates[country].length==0 )
    {
      objFormField.options[0] = new Option("Please enter State/Province ->","");
      objFormField.length=1;
      objFormField.selectedIndex=0;
	  enter_state.style.display='inline';
    }
    else
    {    
      objFormField.options[0] = new Option("Select State/Province","");
      for(var ii=0;ii<jStates[country].length;ii++)
        objFormField.options[ii+1] = new Option(jStates[country][ii],jStateIDs[country][ii]);
      objFormField.length=jStates[country].length + 1;
      objFormField.selectedIndex=0;
	  enter_state.style.display='none';
    }
}

function populateTripDates(form){
    var ixtrip;
	ixtrip = form.trip.selectedIndex - 1;
    form.tripsched.length=0;
    if ( ixtrip < 0 )
    {
      form.tripsched.options[0] = new Option("Select a Date","");
      form.tripsched.length=1;
      form.tripsched.selectedIndex=0;
    }
    else
    {    
      form.tripsched.options[0] = new Option("Select a Date","");
      for(var ii=0;ii<jTripDates[ixtrip].length;ii++)
        form.tripsched.options[ii+1] = new Option(jTripDates[ixtrip][ii],jTripDateIDs[ixtrip][ii]);
      form.tripsched.length=jTripDates[ixtrip].length + 1;
 	  form.tripsched.selectedIndex=0;
    }
}

function enterCountryVisibility(form, getfocus)
{
	var IE = (document.all) ? 1 : 0;
	var DOM = 0; 
	if (parseInt(navigator.appVersion) >=5) {DOM=1};
	if (DOM)
		var enter_country = document.getElementById("enter_country");
	else if(IE)
		var enter_country = document.all["enter_country"];
  if (form.state.options[form.state.selectedIndex].value == "Not in US or Canada"){
	enter_country.style.display='inline';
	if(getfocus == true)
		form.country.focus();
  }
  else 
	enter_country.style.display='none';
}

function checkAvailability(form){
	//var form = document.details;
	if (form.email.value=="")
	{
		alert("Email Address Required");
		return false;
	}
	if ( form.phone_day.value=="" && form.phone_eve.value=="" && form.phone_cell.value=="" )
	{
		alert("We'll need at least one contact phone number to confirm your booking request!");
		return false;
	}
	if (form.tripsched.options[form.tripsched.selectedIndex].value=="")
	{
		alert("Please select the departure date you are interested in!");
		return false;
	}
	if (form.tripsched.options[form.tripsched.selectedIndex].value!="")
		form.trip_text.value = form.trip.options[form.trip.selectedIndex].innerHTML + " " + form.tripsched.options[form.tripsched.selectedIndex].innerHTML;
	if (form.state.options[form.state.selectedIndex].value!="")
		form.state_text.value = form.state.options[form.state.selectedIndex].innerHTML;
	if (form.country.options[form.country.selectedIndex].value!="")
		form.country_text.value = form.country.options[form.country.selectedIndex].innerHTML;

	return true;
}

