function CheckRoomLayoutAccom(cboPassengerCount)
{
	var lAdultsAlloc = 0,lChildrenAlloc = 0;
	var i = 0;
	var el;
	
	//var lPassengers = <%=iif(Request.Form("cboPassengerCount")="",1,Request.Form("cboPassengerCount"))%>;
	
	if(cboPassengerCount=='')
		var lPassengers = 1;
	else
		var lPassengers = cboPassengerCount;
	
		
	for(i=0;i<window.document.frmHolidayCrit.elements.length;i++)
	{
		el = window.document.frmHolidayCrit.elements[i];

		if (el.type == 'select-one')
		{
			if(el.options[el.selectedIndex].value == 'A')
				lAdultsAlloc++;
			if(el.options[el.selectedIndex].value == 'C')
				lChildrenAlloc++;
		}
	}

	if((lAdultsAlloc + lChildrenAlloc) != lPassengers)
	{
		alert("Le nombre d'adultes et d'enfants par chambre est incorrect.\nYou have specified " + lPassengers.toString() + " passengers.");
		return false;
	}

	//Set adults and children
	window.document.frmHolidayCrit.cboAdults.value = lAdultsAlloc;
	window.document.frmHolidayCrit.cboChildren.value = lChildrenAlloc;
	return true;
}


function Next_Accom()
{
		var frm = window.document.frmHolidayCrit;
		var szError = "";

		var dtChkIn = new Date(frm.dtChkInDay.options[frm.dtChkInDay.selectedIndex].value + " " + frm.dtChkInMth.options[frm.dtChkInMth.selectedIndex].value + " " + frm.dtChkInYr.options[frm.dtChkInYr.selectedIndex].value);
		var dtChkOut = new Date(frm.dtChkOutDay.options[frm.dtChkOutDay.selectedIndex].value + " " + frm.dtChkOutMth.options[frm.dtChkOutMth.selectedIndex].value + " " + frm.dtChkOutYr.options[frm.dtChkOutYr.selectedIndex].value);
		var dtNow = new Date();
		var lPassengers = new Number(frm.cboPassengerCount.options[frm.cboPassengerCount.selectedIndex].value);
		var lInfants = new Number(frm.cboInfant.options[frm.cboInfant.selectedIndex].value);

		var dtOutDay = frm.dtChkOutDay.options[frm.dtChkOutDay.selectedIndex].value
		var dtOutMth = frm.dtChkOutMth.options[frm.dtChkOutMth.selectedIndex].value
		var dtOutYr = frm.dtChkOutYr.options[frm.dtChkOutYr.selectedIndex].value
	
		var dtInDay = frm.dtChkInDay.options[frm.dtChkInDay.selectedIndex].value
		var dtInMth = frm.dtChkInMth.options[frm.dtChkInMth.selectedIndex].value
		var dtInYr = frm.dtChkInYr.options[frm.dtChkInYr.selectedIndex].value
		
		if (IsDateAccom(dtOutDay,dtOutMth,dtOutYr)==false)
			szError+="\n - The check-in date selected is not valid";
			
		if (IsDateAccom(dtInDay,dtInMth,dtInYr)==false)
			szError+="\n - The check-out date selected is not valid";
		
		if(DaysDelta(dtNow,dtChkIn)>=0)
			szError+="\n - La date d'arrivee est incorrecte";
		if(DaysDelta(dtChkIn,dtChkOut)>=0)
			szError+="\n - La date d'arrivee doit preceder la date de depart";
		if(lInfants > lPassengers)
			szError+="\n - Le nombre de bebes ne peut exceder le nombre de personnes";
			
		var szResort = window.document.frmHolidayCrit.cboResort.options[window.document.frmHolidayCrit.cboResort.selectedIndex].value;
		if((szResort=='$$NULL$$') || szResort=='')
			szError+="\n - Selectionner une ville";
			
		if(szError!="")
		{
			alert("Les champs suivants n'ont pas ete rempli correctement:\n" + szError);
			return;
		}
	
	if(!CheckRoomLayoutAccom(lPassengers))
		return;
	
	window.document.frmHolidayCrit.action = "accomodation_results.asp";
	window.document.frmHolidayCrit.submit();
}

function getHotelInfo()
{
	szSelected = window.document.frmHolidayCrit.cboCountries.options[window.document.frmHolidayCrit.cboCountries.selectedIndex].value;

	if(null==szSelected ||
		szSelected=='$$OTHER$$' ||
		szSelected == '$$NULL$$' ||
		szSelected == '')
	{
		alert("Selectionnez un pays pour utiliser ce service");
		return;
	}

	window.document.frmHolidayCrit.action = "hotel_list.asp?cboCountries=" + szSelected;
	window.document.frmHolidayCrit.submit();
}

function getResortInfoAccom()
{
	//resort_list.asp
	szSelected = window.document.frmHolidayCrit.cboCountries.options[window.document.frmHolidayCrit.cboCountries.selectedIndex].value;

	if(null==szSelected ||
		szSelected=='$$OTHER$$' ||
		szSelected == '$$NULL$$' ||
		szSelected == '')
	{
		alert("Selectionnez un pays pour utiliser ce service");
		return;
	}

	window.document.frmHolidayCrit.action = "resort_list.asp?cboCountries=" + szSelected;
	window.document.frmHolidayCrit.submit();
}

function RefreshPageAccom()
{
	window.document.frmHolidayCrit.submit();
}

function cboCountriesAccom_onchange() {
	var szSelected = window.document.frmHolidayCrit.cboCountries.options[window.document.frmHolidayCrit.cboCountries.selectedIndex].value;

	if(szSelected!='$$NULL$$')
	{
		if(szSelected=='$$OTHER$$'){
			//window.open('http://tawl.holiday.co.uk/default.asp?WebsiteGUID={7fc411e5-ce5d-43de-97fb-faa9def4d5ef}');
			window.document.frmHolidayCrit.method = "GET";
			window.document.frmHolidayCrit.action = "frameset.html";
			window.document.frmHolidayCrit.submit();
			return;
		}

		//window.document.frmHolidayCrit.action = "accomodation_criteria.asp";
		window.document.frmHolidayCrit.action = "main.asp?searchmode=accommodation";
		window.document.frmHolidayCrit.submit();
	}
	else
	{
		//window.document.frmHolidayCrit.action = "accomodation_criteria.asp";
		window.document.frmHolidayCrit.action = "main.asp?searchmode=accommodation";
		window.document.frmHolidayCrit.submit();
	}
}

function cboResortAccom_onchange() {
	var szSelected = window.document.frmHolidayCrit.cboResort.options[window.document.frmHolidayCrit.cboResort.selectedIndex].value;

	if(szSelected!='$$NULL$$')
	{
		if(szSelected=='$$OTHER$$'){
			window.open('http://tawl.holiday.co.uk/default.asp?WebsiteGUID={7fc411e5-ce5d-43de-97fb-faa9def4d5ef}');
			return;
		}

		window.document.frmHolidayCrit.txtResort.value = window.document.frmHolidayCrit.cboResort.options[window.document.frmHolidayCrit.cboResort.selectedIndex].text;
		window.document.frmHolidayCrit.action = "main.asp?searchmode=accommodation"; //"accomodation_criteria.asp";
		window.document.frmHolidayCrit.submit();
	}
	else
	{
		alert("Selectionner une ville");
	}
}


function changeSelectionAccom(source,target)
{
	target.selectedIndex = source.selectedIndex;
	updateDaysAccom();
}
function updateDaysAccom()
{
	//update day of week
	var days = new Array("Dim","Lun","Mar","Mer","Jeu","Ven","Sam");
	var dtOut = new Date(window.document.frmHolidayCrit.dtChkOutDay.options[window.document.frmHolidayCrit.dtChkOutDay.selectedIndex].value + " " + window.document.frmHolidayCrit.dtChkOutMth.options[window.document.frmHolidayCrit.dtChkOutMth.selectedIndex].value + " " + window.document.frmHolidayCrit.dtChkOutYr.options[window.document.frmHolidayCrit.dtChkOutYr.selectedIndex].value);
	var dtIn = new Date(window.document.frmHolidayCrit.dtChkInDay.options[window.document.frmHolidayCrit.dtChkInDay.selectedIndex].value + " " + window.document.frmHolidayCrit.dtChkInMth.options[window.document.frmHolidayCrit.dtChkInMth.selectedIndex].value + " " + window.document.frmHolidayCrit.dtChkInYr.options[window.document.frmHolidayCrit.dtChkInYr.selectedIndex].value);

	window.lblOutDay.innerText = '(' + days[dtOut.getDay()] + ')';
	window.lblInDay.innerText = '(' + days[dtIn.getDay()] + ')';
}

function IsDateAccom(dtDay,dtMth,dtYr)
{
	var dtDate = new Date(dtDay + " " + dtMth + " " + dtYr);
		if (dtDate.getDate() != dtDay)
			return false;
		else
			return true;
}