	// omniture 
	s_account="opodofrprod";
	s.pageName="Op:FR:MoteurSejourPromo:Search";
	s.channel="PROMO-tab";
	s.campaign=s.getQueryParam('CMP');
  
  //decalage jours entre aller et retour
	var dpDelay = 3;
	var volDelay=7;
	var rechercherVolHotel = false;
	var volHotel_ValidationDate = false;
	
$(document).ready(function() {
 
	// date d'aujourd'hui    
	var today = new Date ();
	// remplir la liste des  mois
	
	fillDepMonthSejour("depMonth",13, "","",today,"YYYYMM"); //sejours
	refillDepDaySejour('depMonth','addepDay','--','','DD','MMM YYYY');	
	//On gère l'envoi du formulaire sejour
	
	
	$("#depMonth").change(function(){
		refillDepDaySejour('depMonth','addepDay','--','','DD','MMM YYYY');
	});		
	
	
	$('#formSejour').submit(function() {
		tracking(document.getElementById("rechercheSejour"),'Op:FR:Homepage:Search_PkgSubmitButton');
		return submitFromSejour() ;
		return true;
	});
	
	 

});

  
	
	// Onsubmit Sejour
function submitFromSejour() {
		
	var monthYear =  $("#depMonth").val();
	var day	=	$("#addepDay").val();
	var departureDateTab = monthYear.split("-");
	
	if(day!=''){
			
		if (day.substring(0,1)=='0')
			day=day.substring(1,2);
			
			$("#depDay").val(monthYear+'-'+day);
			
		}
		else
			$("#depDay").val('');
		return true;
				
}

	
	
function refillDepDaySejour(idSelectDepMonth, idSelectDepDay, firstOptionText, firstOptionValue, dayMask, monthYearMask){
	
	var selectDepDay = document.getElementById(idSelectDepDay);
	var selectedDay = selectDepDay.value;
	var selectDepMonth  = document.getElementById(idSelectDepMonth);
	var monthYear = selectDepMonth.value;
	
	var year = 0;
	var numericMonth = 0;
	//MMM YYYY
	if(monthYearMask == "MMM YYYY" ){
		year  = monthYear.substring(0,monthYear.indexOf("-"));
		var month = monthYear.substring(monthYear.indexOf("-")+1, monthYear.length);
		
		/*for(var i=0; i< FRENCH_MONTHS_SHORT.length; i++)
			if(FRENCH_MONTHS_SHORT[i] == month)
		*/
		numericMonth = month-1;
	}
	
	else{	//monthYearMask == "YYYYMM"
		year = monthYear.substring(0,4);
		numericMonth = monthYear.substring(4,6);
		numericMonth = numericMonth -1; // months goes from 0 to 11
		
	}
	
	var dateMonth = new Date();
	dateMonth.setYear(year);
	dateMonth.setMonth(numericMonth);
	
	
	//if the selected month is the actual one, we don't allow a departure day < today
	var today = new Date();
	if(today.getYear() == dateMonth.getYear() && today.getMonth() == dateMonth.getMonth() ){
		
		//important: we cannot set the day directly because could happen that we try to set day 31 to february!!
		var thisMonth = new Date(today.getYear(), today.getMonth(), 0);
		var daysInActualMonth = thisMonth.getDate();
		
		if( daysInActualMonth < selectedDay )
			dateMonth.setDate(daysInActualMonth);
		else	
			dateMonth.setDate(today.getDate());
		
		if (today.getDate() > dateMonth.getDate() ){
			//we change the selected day
			selectedDay = today.getDate();
		}
	}else
		dateMonth.setDate(1);
	
	fillDepDay(idSelectDepDay, dateMonth, selectedDay, firstOptionText, firstOptionValue, dayMask);
}



function fillDepMonthSejour(idSelectDepMonth, nbrOfMonths, firstOptionText, firstOptionValue, selectedMonthDate, monthYearMask){
	
	var today = new Date();
	today.setDate(1);

	var selectDepMonth  = document.getElementById(idSelectDepMonth);

	var monthString;
	var monthSelected;
	var newOptions = new Array();

	var optionOffset = 0;
	if (firstOptionText != "" ){
		var mySelectOption = new Option(firstOptionText,firstOptionValue);
		selectDepMonth.options[0] = mySelectOption;
		optionOffset = 1;
	}



	var mySelectOption = new Option("Indifférent","",true);
	selectDepMonth.options[0] = mySelectOption;
	selectDepMonth.options[0].selected =true;


	for (var i= 2; i<=nbrOfMonths+1; i++)
	{
		monthSelected = false;
		var twoLastDigitsYear = ""+today.getFullYear();	//we convert the number to a string
		twoLastDigitsYear = twoLastDigitsYear.substring(twoLastDigitsYear.length-2,twoLastDigitsYear.length);
		
		var monthText  = FRENCH_MONTHS[today.getMonth()]+" "+twoLastDigitsYear;
		
		var monthValue = "";
		
		if(monthYearMask == "MMM YYYY" ){
			monthValue = FRENCH_MONTHS_SHORT[today.getMonth()]+" "+today.getFullYear();
		}
		else{	//monthYearMask == "YYYYMM"
			var numericMonth = today.getMonth()+1;	//month goes from 0 to 11
			var monthString = (numericMonth<10?"0":"")+numericMonth;
			monthValue = ""+today.getFullYear()+"-"+monthString;
		}
		
		//For info: new Option([text[, value[, defaultSelected[, selected]]]])
		mySelectOption = new Option(monthText,monthValue,monthSelected);
		selectDepMonth.options[i-1+optionOffset] = mySelectOption;
		selectDepMonth.options[i-1+optionOffset].selected = monthSelected;
		
		today.setMonth(today.getMonth()+1);	//we increment the month for the next iteration
	}
}
		
	

