/*****
 * Copyright © FASTBOOKING  2000-2006
 *
*/

var FBRESA = "http://www.fastbookings.biz/DIRECTORY/";


// search availabilities for selected promotions
function hhotelSearchPromo(cluster, lg, theme)
{
	hhotelSearch(cluster, lg, "", "", "", theme, "");
}

// Main Search function
function hhotelSearch(cluster, lg, price, nights, title, theme, args)
{
	var waction = FBRESA + "crs.phtml?clusterName="+cluster;
	if (lg != "") waction += "&langue="+lg;
	if (price != "") waction += "&FSTBKNGCode="+price;
	if (nights != "") waction += "&nights="+nights;
	if (title != "") waction += "&title="+escape(title);
	if (theme != "") waction += "&theme="+theme;
	if (args != "" && (args.indexOf("=")!= -1) ) waction += "&"+args;
	window.open(waction,"search","toolbar=no,width=800,height=550,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}


///////////////////////////////////////////////////////////////////////////////////////
// Form functions
// Simple form validation (used for compatibility issues)
function hhotelDispoprice(myForm)
{
	hhotelFormValidation(myForm, 0);
}

// Form validation with control
function hhotelFormValidation(myForm, mandatoryCode){
	if (mandatoryCode == 1 && myForm.AccessCode.value == "") {
		alert("You must type in your code ID");
		return (false);
	}
	var languetype = typeof myForm.action;
	myForm.action = FBRESA + "dispoprice.phtml";
	window.open('','dispoprice', 'toolbar=no,width=800,height=550,menubar=no,scrollbars=yes,resizable=yes');
	myForm.submit();
	return (true);
}

// Form: update the selected hotel name
function hhotelFormUpdateHotelnames(myForm)
{
	menuNum = myForm.HotelList.selectedIndex;
	if (menuNum == null)
		return;
	myForm.Hotelnames.value = myForm.HotelList.options[menuNum].value;
}

// Form: show the cancel page
function hhotelFormCancel(myForm){
	var CName = myForm.Hotelnames.value;
	var languetype = typeof myForm.langue;
	var langue;
	if (languetype == "undefined")
		langue = "";
	else
		langue = myForm.langue.value;
	if (CName == null || CName == 'All' || CName == ''){ alert('Please select a hotel first'); return (false); }
	return hhotelcancel(CName, langue);
}
// Form: show arrival date

function start()
{

var nbm = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];

jour = 7;

MD=new Date();

nday=MD.getDate();
aday=MD.getDay();
amois=MD.getMonth();
ayear=takeYear(MD);


nday += jour;

if(nday > nbm[amois])
{   		
	nday -= nbm[amois]; 
	amois++;  
	if(amois > 11) { ayear++; amois = 0; } }

indexDay = nday-1;
indexMois = amois;
indexYear = ayear-2006;

if(indexDay < 0 || indexDay > 30) indexDay = 0;
if(indexMois < 0 || indexMois > 11) indexMois = 0;
if(indexYear < 0 || indexYear > 1) indexDay = 0;

document.idForm.fromday.selectedIndex = indexDay;
document.idForm.frommonth.selectedIndex = indexMois; 
document.idForm.fromyear.selectedIndex = indexYear;

}

function takeYear(theDate)
{
        x = theDate.getYear();
        var y = x % 100;
        y += (y < 38) ? 2000 : 1900;
        return y;
}
