overrideFormName = false;
var activeSE = '';
var activeName = '';
var activeGmap = false;
//preloading alphacube images
pic1= new Image(); 
pic1.src="/STATICS/imgs/commons/ajaxloader.gif";

pic2= new Image(); 
pic2.src="/STATICS/imgs/prototype/alphacube/left-top.gif"; 

pic3= new Image(); 
pic3.src="/STATICS/imgs/prototype/alphacube/top-middle.gif"; 

pic4= new Image(); 
pic4.src="/STATICS/imgs/prototype/alphacube/right-top.gif"; 

pic5= new Image(); 
pic5.src="/STATICS/imgs/prototype/alphacube/frame-left.gif"; 

pic6= new Image(); 
pic6.src="/STATICS/imgs/prototype/alphacube/frame-right.gif"; 

pic7= new Image(); 
pic7.src="/STATICS/imgs/prototype/alphacube/bottom-left-c.gif"; 

pic8= new Image(); 
pic8.src="/STATICS/imgs/prototype/alphacube/bottom-middle.gif"; 

pic9= new Image(); 
pic9.src="/STATICS/imgs/prototype/alphacube/bottom-right-c.gif"; 

function search(code, w, h, top, left, lg)
{
	if(code != undefined && code != "")
		$("zone").value = code;

	if (parseInt($("zone").value) < 0)
	{
		if (alert_city != undefined)
			alert(alert_city);
		else
			alert('Select a city');
		return;
	}

	/*
	var arrival_date = $F("fromdate");
	var nb_adult = $F("nbadult");
	var nb_child = $F("nbchild");
	var currency = $F("currency");
	var nb_days = $F("nbdays");
	var zone = $F("zone");
	*/
	//console.log("date:"+arrival_date+"\nadult:"+nb_adult+"\nchild:"+nb_child+"\ncurrency:"+currency+"\nnbdays:"+nb_days+"\nzone:"+zone);

	if (overrideFormName==true)
		$("idForm2").submit();
	else
		$("idForm").submit();

	if(w == undefined)
		w = 500;
	if(h == undefined)
		h = 200;
		
	if(top != undefined) elmt_top = top;
	if(left != undefined) elmt_left = left;

	if(typeof(elmt_w) != "undefined") w = elmt_w;
	if(typeof(elmt_h) != "undefined") h = elmt_h;
	
	if($('moteur_carte'))
		$('moteur_carte').style.visibility = 'hidden';

	if($('flash_promo'))
		$('flash_promo').style.visibility = 'hidden';
		
	if($("quicksearchphoto"))
		$('quicksearchphoto').style.visibility = 'hidden';
		
	if($("quicksearchvideo"))
		$('quicksearchvideo').style.visibility = 'hidden';

	Dialog.info(pop_title + "<br><img src='/STATICS/imgs/commons/ajaxloader.gif' border='0' vspace='20'>", {width:w, height:h, top:elmt_top, left:elmt_left, className: "alphacube"});
}



function search_quick(code, w, h, top, left)
{

	//prepare all needed attributes
	var attr = "action=hotel";
		//attr += "&page="+$F("crtPage");
		attr += "&page="+$F("currentPage");
		attr += "&site="+activeSite;
		attr += "&lg="+$F("pushLanguage");
		attr += "&quicksearch=request";
		attr += "&cname="+$F("cname");
		attr += "&fromdate="+$F("fromdate");
		attr += "&fromdate_txt="+$F("fromdate_txt");
		attr += "&nbdays="+$F("nbdays");
		attr += "&nbadults="+$F("nbadults");
		attr += "&currency="+$F("currency");
		if (document.getElementById('landing')!=null)
			attr += "&landing="+$F("landing");

	if ((activeSE=='') && (document.getElementById('bloc_search_engine_video')!=null))
	{
		activeSE = document.getElementById('bloc_search_engine_video').innerHTML;
		activeName = 'bloc_search_engine_video';
		usingObj = document.getElementById('bloc_search_engine_video');
		usingObjold = usingObj;

	}
	else
		if ((activeSE=='') && (document.getElementById('bloc_search_engine_photo')!=null))
		{
			activeSE = document.getElementById('bloc_search_engine_photo').innerHTML;
			activeName = 'bloc_search_engine_photo';
			usingObj = document.getElementById('bloc_search_engine_photo');
			usingObjold = usingObj;
		}


	//usingObj.update("<div><br><br><br><br><br><br><table align=center><tr><td><img src='/STATICS/imgs/commons/ajaxloader.gif' border='0' vspace='20'><br></td></tr></table></div>");
	usingObj.innerHTML = "<div><br><br><br><br><br><br><table align=center><tr><td><img src='/STATICS/imgs/commons/ajaxloader.gif' border='0' vspace='20'><br></td></tr></table></div>";

	var myAjax = new Ajax.Request(
                    '../../PHP/anyscript.php',
                    {
                        method: 'post',
                        parameters: attr,
                        asynchronous: true,
                        onComplete: showResponse,
                        contentType:'application/x-www-form-urlencoded',
                        encoding: 'UTF-8'
                    });

        function showResponse(originalRequest)
        {
			var result = originalRequest.responseText;
			usingObj.innerHTML = originalRequest.responseText;
			usingObjold.innerHTML=usingObj.innerHTML;
			document.getElementById("result").style.display = 'block';
		}
}







function ShowPage(page)
{
	querystring = "?page="+page;
	/*
	querystring+= "&day="+d;
	querystring+= "&month="+m;
	querystring+= "&year="+y;
	querystring+= "&nbdays="+night;
	querystring+= "&nbadult="+adult;
	querystring+= "&nbchild="+child;
	querystring+= "&currency="+currency;
	*/
	//alert(querystring);
	location.href=querystring;
}

function hhotelResaDistOTP(cname, lg, codeprice, codetrack, firstroom, firstdate, CurrencyLabel)
{
	var waction = "http://www.fastbookings.biz/DIRECTORY/preresa.phtml?Hotelnames="+cname;
        if (lg != "") waction += "&langue="+lg;
        waction += "&style=DIRECT";
        waction += "&clustername=NO";   // no cross-selling
        if (codeprice != "") waction += "&FSTBKNGCode="+codeprice;
        else waction += "&FSTBKNGCode=FB-DISTRIB";
        waction += "&FSTBKNGTrackLink="+codetrack;
        if (firstroom != "") waction += "&FirstRoomName="+firstroom;
        if (firstdate != "") waction += "&FirstDate="+firstdate;
        waction += "&so=8";
        if (CurrencyLabel != "") waction += "&CurrencyLabel="+CurrencyLabel;

        window.open(waction,"reservation","toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}

function hhotelResaDist(cname, lg, codeprice, codetrack, firstroom, firstdate, CurrencyLabel)
{
	var waction = "http://www.fastbookings.biz/DIRECTORY/preresa.phtml?Hotelnames="+cname;
	if (lg != "") waction += "&langue="+lg;
	waction += "&style=DIRECT";
	waction += "&clustername=NO";	// no cross-selling
	if (codeprice != "") waction += "&FSTBKNGCode="+codeprice;
	else waction += "&FSTBKNGCode=FB-DISTRIB";
	waction += "&FSTBKNGTrackLink="+codetrack;
	if (firstroom != "") waction += "&FirstRoomName="+firstroom;
	if (firstdate != "") waction += "&FirstDate="+firstdate;
	waction += "&so=3";
	if (CurrencyLabel != "") waction += "&CurrencyLabel="+CurrencyLabel;
	
	window.open(waction,"reservation","toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}

function hwindow(url) {
	window.open(url, 'infos', 'status=yes,location=yes,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,alwaysRaised=yes');
	return false;
}
function hhistory(url) {
	window.open(url, 'history', 'status=no,location=no,toolbar=no,width=600,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes');
	//return false;
}

function salescondition(url)
{
	var domaine = "http://portal.fastbooking-sa.fr/fiche/conditions.phtml?";
	domaine += url;
	window.open(domaine, 'salescond', 'status=no,location=no,toolbar=no,width=600,height=600,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes');
}

//xiti
function xt_clic(typecl,site,section,page,url,nvlle)
{
Xt_r = document.referrer;
Xt_h = new Date();
xt_img = new Image();
Xt_i = 'http://logi7.xiti.com/hit.xiti?s='+site+'&s2='+section;
Xt_i += '&p='+page+'&clic='+typecl+'&hl=' + Xt_h.getHours() + 'x' + Xt_h.getMinutes() + 'x' + Xt_h.getSeconds();
if(parseFloat(navigator.appVersion)>=4)
{Xiti_s=screen;Xt_i += '&r=' + Xiti_s.width + 'x' + Xiti_s.height + 'x' + Xiti_s.pixelDepth + 'x' + Xiti_s.colorDepth;}
Xt_i += '&ref=' + Xt_r.replace(/[<>]/g, '').replace(/&/g, '$');
xt_img.src = Xt_i;
if (url != null)
{ if ((nvlle=='')||(nvlle==null)) { document.location = url;} else {xfen = window.open(url,'xfen',''); xfen.focus();}}
else
{return;}
}

var mydomain = "fastbooking";
function printMail(user) {
	var address = user + "@" + mydomain;
	document.writeln(address + "." + "com");
}

// put all partners here
var dist_partners = new Array(
"C2P", "http://www.cometoparis.com/imgtrack_orig.php"
						);

function DistTrackingForPartners(partner)
{
	for(i=0; i<dist_partners.length; i=i+2)
	{
		if(partner == dist_partners[i])
		{
			var trackimg = new Image();
			var h = new Date();
			var url = dist_partners[i+1];
			url+="?t="+ h.getHours();
			url+="x" + h.getMinutes();
			url+="x" + h.getSeconds();		
			trackimg.src = url;
			//alert(url);
		}
	}
}

function WindowCancel()
{
	waction = "http://portal.fastbooking-sa.fr/fiche/cancel.phtml";
	window.open(waction,"cancel","toolbar=no,width=650,height=550,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}

function WindowDetails()
{
	waction = "http://portal.fastbooking-sa.fr/fiche/history.phtml";
	window.open(waction,"history","toolbar=no,width=600,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}


function upd(divName, hotelName, lg, site)
{
 var attr = "refresh=true";
	attr += "&page="+hotelName;
	attr += "&site="+activeSite;
	attr += "&lg="+lg;
	attr += "&action=hotel";
	attr += "&quicksearch=request";

	var myAjax = new Ajax.Request(
	    '../../PHP/anyscript.php',
	    {
		method: 'post',
		parameters: attr,
		asynchronous: true,
		onComplete: showResponse,
		contentType:'application/x-www-form-urlencoded',
		encoding: 'UTF-8'
	    });

	function showResponse(originalRequest)
	{
		var result = originalRequest.responseText;
		document.getElementById(divName).innerHTML = result;
		switchSearchEngine(1);
	}
}


function loadPreviousSE(divName, hotelName, lg, site)
{
	if ((activeSE=='') || (activeSE==null))
	{
		upd(divName, hotelName, lg, site);
	}
	else
	{
		
		document.getElementById("criteria").style.display = 'block';
		document.getElementById("result").style.display = 'none';
		document.getElementById(activeName).innerHTML = usingObjold.innerHTML;
	}

//init calendar
	
}


function playVideo(post_url)
{
	var input_m = document.createElement("form");
	input_m.setAttribute("method", "post");
	input_m.setAttribute("name", "tempForm");
	input_m.setAttribute("id", "tempForm");
	input_m.setAttribute("action", post_url);
		

	document.body.insertBefore(input_m, document.body.firstChild);


	var sendValue = document.createElement("input");
	sendValue.setAttribute("name", "videoAutoplay");
	sendValue.setAttribute("type", "hidden");
	document.getElementById("tempForm").appendChild(sendValue);

	document.getElementById("tempForm").submit();
}


function showGoogleIcons()
{
	for(i=0;i<100;i++)
	{
		if (document.getElementById("gen_ggl_div_"+i) != null)
			document.getElementById("gen_ggl_div_"+i).style.display = 'inline';
	}
return;
}


function hhotelDispopriceFHP(cluster, cname, lg, codetrack, year, month, day, nights, currency, nbadults)
{//cluster, cname, lg, codetrack, year, month, day, nights, currency
	if (nbadults == "")
		nbadults = 1;

	if(year=='')
	{
		firstdate = document.getElementById('arrdate_txt').value;
		firstdate = firstdate.split('/');
		year = firstdate[0];
		if(year.length==2)
		{
			month = firstdate[1];
			day = firstdate[0];
			year = firstdate[2];
		}
		else
		{
			month = firstdate[1]
			day = firstdate[2];
		}
		nights = document.getElementById('nonights').innerHTML;
		var index = document.getElementById('currency').selectedIndex;
		currency = document.getElementById('currency').options[index].value;

	}

	hhotelDispopriceFHP_(cluster, cname, lg, codetrack, year, month, day, nights, currency, nbadults);
}


function hhotelDispopriceFHP_(cluster, cname, lg, codetrack, year, month, day, nights, currency, nbadults)
{//cluster, cname, lg, codetrack, year, month, day, nights, currency
	var waction = "http://www.fastbooking.co.uk/DIRECTORY/dispoprice.phtml?clusterName="+cluster;
	if (lg != "") waction += "&langue="+lg;
	waction += "&Hotelnames="+cluster;
	waction += "&FSTBKNGTrackLink="+codetrack;
	if (day != "") waction += "&fromday="+day;
	if (month != "") waction += "&frommonth="+month;
	if (year != "") waction += "&fromyear="+year;
	waction += "&nbdays="+nights;
	if (currency != "") waction += "&CurrencyLabel="+currency;
	waction += '&showPromotions=1';
	waction += '&so=9';
	waction += '&adulteresa='+nbadults;
	window.open(waction,"reservation","toolbar=no,width=800,height=550,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}

