function validateDestination(destinationSelectOptions, lang)
{
  var dSelect = document.getElementById(destinationSelectOptions);
  if (dSelect.options[dSelect.selectedIndex].value=='')
   {
      dSelect.focus();
      if (lang == 'fr'){
  			alert('Destination Invalide. SVP choisir une ville et non un pays.');
			}
      else {
  			alert('Invalid destination. Please choose a city instead of a country');
			}

      return false;
   }

  return true;
}

function changeDaysArray(selectedMonth, daysArray, selectedYear, dayValue )
{
	var part1         = document.forms['VacationSearchForm'];
	var selectedMonth = document.getElementById(selectedMonth);
	var daysArray     = document.getElementById(daysArray);
	var selectedYear  = document.getElementById(selectedYear);

	//get current selected index
	var j = 0;
	var i = 0;
	if ( daysArray != null )
	{
		j = daysArray.selectedIndex;
	}
	// clear default options days array
	if ( daysArray.options != null )
	{
  	daysArray.options.length = 0;
	}
	//test selectedMonth and set list options for days array

	if ( selectedMonth.options[selectedMonth.selectedIndex].value =='1' || selectedMonth.options[selectedMonth.selectedIndex].value =='3'  ||
	    selectedMonth.options[selectedMonth.selectedIndex].value =='5' || selectedMonth.options[selectedMonth.selectedIndex].value =='7'  ||
	    selectedMonth.options[selectedMonth.selectedIndex].value =='8' || selectedMonth.options[selectedMonth.selectedIndex].value =='10' ||
	    selectedMonth.options[selectedMonth.selectedIndex].value =='12'  )
	{
	  for(i=1; i<32; i++){ daysArray.options[i-1] = new Option(String(i),String(i)); }
	}

	if (selectedMonth.options[selectedMonth.selectedIndex].value=='4' || selectedMonth.options[selectedMonth.selectedIndex].value=='6'
	   || selectedMonth.options[selectedMonth.selectedIndex].value=='9' || selectedMonth.options[selectedMonth.selectedIndex].value=='11' )
	{
		for(i=1; i<31; i++) { daysArray.options[i-1] = new Option(String(i),String(i)); }
	}

	var yearMod4 = (new Date()).getYear() % 4;
	if (selectedYear != null && selectedYear.options != null )
	{
  	yearMod4 = parseInt(selectedYear.options[selectedYear.selectedIndex].value) % 4;
	}

	if (selectedMonth.options[selectedMonth.selectedIndex].value=='2' &&  yearMod4 != 0)
	{
		for(i=1; i<29; i++){ daysArray.options[i-1] = new Option(String(i),String(i)); }
	}

	if (selectedMonth.options[selectedMonth.selectedIndex].value=='2' &&  yearMod4 == 0)
	{
	    for(i=1; i<30; i++) { daysArray.options[i-1] = new Option(String(i),String(i)); }
	}

	if (daysArray != null && daysArray.options != null )
	{
	   if (daysArray.options != null && j < daysArray.options.length && j >= 0 ) { daysArray.selectedIndex = j; }
	   else {   if ( parseInt((new Date()).getDate()) +6 < daysArray.options.length )
	             { daysArray.selectedIndex = parseInt((new Date()).getDate()) +6 ; }
	            else
	             { daysArray.selectedIndex = 0 ; }
	        }
	}

	if (dayValue !=null )
	{
	  var i = 0;
	  while (i < daysArray.options.length  )
		{
	  	if (daysArray.options[i].value == dayValue )
		  {  break; }
	    else  i = i+1;
	  }

		if ( i < daysArray.options.length)  { daysArray.selectedIndex = i ; }
	}

}
function chgBook(aChanger) {

	if(aChanger == 'Vol') {
		document.getElementById('radio1').checked = true;
		document.getElementById('frmBookForfait').style.display = "none";
		document.getElementById('frmBookVol').style.display = "";
		//document.getElementById('ong_vol').style.backgroundColor = "#FBECCD";
		//document.getElementById('ong_car').style.backgroundColor = "#E9D4A5";	
		//document.getElementById('ong_forfait').style.backgroundColor = "#E9D4A5";		
	} else if(aChanger == 'Forfait') {
		document.getElementById('radio0').checked = true;
		document.getElementById('frmBookForfait').style.display = "";
		document.getElementById('frmBookVol').style.display = "none";
		//document.getElementById('ong_forfait').style.backgroundColor = "#FBECCD";
		//document.getElementById('ong_car').style.backgroundColor = "#E9D4A5";	
		//document.getElementById('ong_vol').style.backgroundColor = "#E9D4A5";		
	}
	
}

function switchFlightType(aChanger) {
	if(aChanger == 'roundTrip') {
	 	document.getElementById('roundTrip1').style.display = "";
		document.getElementById('roundTrip2').style.display = "";
		document.getElementById('roundTrip3').style.display = "";
		document.getElementById('roundTrip4').style.display = "";
		document.frmAirSearch.radioLegNum[0].checked=true;

	} else {
		document.getElementById('roundTrip1').style.display = "none";
		document.getElementById('roundTrip2').style.display = "none";
		document.getElementById('roundTrip3').style.display = "none";
		document.getElementById('roundTrip4').style.display = "none";
		document.frmAirSearch.radioLegNum[1].checked=true;
	}
}

function arrangerDate() {
	date_complet = document.frmAirSearch.depDateCalendar.value;
	date_complet_array = date_complet.split("/");
	
	var jour = date_complet_array[0]; 
	var mois = date_complet_array[1]; 
	var annee = date_complet_array[2];

	document.frmAirSearch.csDepDate0.value = annee+'-'+mois+'-'+jour;
	
	date_complet = document.frmAirSearch.depDateCalendar2.value;
	date_complet_array = date_complet.split("/");
	
	var jour = date_complet_array[0]; 
	var mois = date_complet_array[1]; 
	var annee = date_complet_array[2];

	document.frmAirSearch.csDepDate1.value = annee+'-'+mois+'-'+jour;
	
}

function arrangerDateDep() {
	date_complet = document.TourSearchForm.dateCalendar.value;
	date_complet_array = date_complet.split("/");
	
	var jour = date_complet_array[0]; 
	var mois = date_complet_array[1]; 
	var annee = date_complet_array[2];
	
	document.TourSearchForm.nDepDay.value = jour;
	document.TourSearchForm.nDepMonth.value = mois;
	document.TourSearchForm.nDepYear.value = annee;
	
	
}

function arrangerDateAuto() {
	date_complet = document.frmCarSearch.depDateCalendar.value;
	date_complet_array = date_complet.split("/");
	
	var jour = date_complet_array[0]; 
	var mois = date_complet_array[1]; 
	var annee = date_complet_array[2];

	document.frmCarSearch.csPickupDate.value = annee+'-'+mois+'-'+jour;
	
	date_complet = document.frmCarSearch.depDateCalendar2.value;
	date_complet_array = date_complet.split("/");
	
	var jour = date_complet_array[0]; 
	var mois = date_complet_array[1]; 
	var annee = date_complet_array[2];

	document.frmCarSearch.csDropOffDate.value = annee+'-'+mois+'-'+jour;

	
}

