/*****
 * Copyright © FASTBOOKING  2000-2003
 *
*/

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


// standard booking function
function hhotelPTC(cname, lg, codeprice, codetrack, cluster)
{
	hhotelResa(cname, lg, codeprice, "", "", codetrack, cluster, "", "")
}

// standard promotion function
function hhotelPromo(cname, lg, theme)
{
	hhotelResa(cname, lg, "DYNPROMO", "", "", "", "", theme, "")
}

// reservation page WITHOUT the individual access
function hhotelNegociated(cname, lg, codeprice, codetrack, cluster)
{
	hhotelResa(cname, lg, codeprice, "", "", codetrack, cluster, "", "negociated=1");
}

// standard search availabilities in a group
function hhotelSearchGroup(cluster, lg, price, nights, title)
{
	hhotelSearch(cluster, lg, price, nights, title, "", "");
}

// standard search availabilities in a group for a partner
function hhotelSearchPartner(cluster, lg, price, codetrack, title)
{
	if (codetrack != "") args = "&from="+codetrack;
	else	args = "";
    hhotelSearch(cluster, lg, price, "", title, "", args);
}

// search by giving the initial date
function hhotelSearchPriceDate(cluster, price, nights, title, firstdate)
{
	// firstdate : format "YYMMDD"
	var args="";
	if (firstdate != "") args = "FirstDate="+firstdate;
	hhotelSearch(cluster, "", price, nights, title, "", args);
}

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

// go to the cancel reservation page
function hhotelcancel(cname,lg)
{
	var waction = FBRESA + "cancel.phtml?state=77&Hotelnames="+cname;
	if (lg != "") waction += "&langue="+lg;
	window.open(waction,"reservation","toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}

// go to the extract reservation page
function hhotelExtract(cname, lg)
{   
	var waction = FBRESA + "getresa.phtml?Hotelnames="+cname+"&langue="+lg;
	window.open(waction, 'getresa', 'toolbar=no,width=700,height=300,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes');
   return false;
}

// check interface
function hhotelcheckrates(cname, lg)
{
	var waction = FBRESA + "crs.phtml?clusterName="+cname;
	if (lg != "") waction += "&langue="+lg;
	waction += "&checkPromo=1";
	window.open(waction,"search","toolbar=no,width=750,height=550,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}


// Main standard reservation function
function hhotelResa(cname, lg, codeprice, firstroom, firstdate, codetrack, cluster, theme, args)
{
	var waction = FBRESA+"preresa.phtml?Hotelnames="+cname;
	if (lg != "") waction += "&langue="+lg;
	if (firstroom != "") {
		waction += "&FirstRoomName="+firstroom;
		if (codeprice == "")
			codeprice = "DIRECT";
		}
	if (firstdate != "") {
		waction += "&FirstDate="+firstdate;
		if (codeprice == "")
			codeprice = "DIRECT";
		}
	if (codeprice != "") waction += "&FSTBKNGCode="+codeprice;
	if (codetrack != "") waction += "&FSTBKNGTrackLink="+codetrack;
	if (cluster != "") waction += "&clustername="+cluster;
	if (theme != "") waction += "&theme="+theme;
	if (args != "" && (args.indexOf("=")!= -1) ) waction += "&"+args;
	waction += "&HTTP_REFERER="+escape(document.location.href);
	window.open(waction,"reservation","toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}

// 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=750,height=550,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}

// Main Search function for Multi Codes
function hhotelSearchMultCode(cluster, lg, clecode, title, codetrack)
{
	var waction = FBRESA + "crs.phtml?clusterName="+cluster;
	if (lg != "") waction += "&langue="+lg;
	if (clecode != "") waction += "&AccessCode="+clecode;
	if (title != "") waction += "&title="+escape(title);
	if (codetrack != "") waction += "&FSTBKNGTrackLink="+codetrack;
	window.open(waction,"search","toolbar=no,width=750,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=700,height=600,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 the extract page
function hhotelFormExtract(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 hhotelExtract(CName, langue);
}
