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');
	}

function getFirstDate()
{
  var searcht = "firstdate=";
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(searcht)
      if (offset != -1) { // if cookie exists
         offset += searcht.length
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset)
         // set index of end of cookie value
         if (end == -1)
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end));
      } 
   }
   return "";
}

function hhoteldistrib(hname, lg, codeprice, codetrack, firstroom, firstdate)
{
	var waction = "http://portal.fastbooking-sa.fr/fiche/resa.phtml?HotelName="+hname;
	if (lg != "") waction += "&langue="+lg;
	waction += "&style=DIRECT";
	waction += "&clustername=NO";	// no cross-selling
	if (codeprice != "") waction += "&FSTBKNGCode="+codeprice;
	else waction += "&FSTBKNGCode=FB-DISTRIB";
	//if (codetrack != "") waction += "&FSTBKNGTrackLink="+codetrack;
	codetrack = getOrigin();
	if (codetrack.length == 0) {
		codetrack = defaultFromValue;
	}
	waction += "&FSTBKNGTrackLink="+codetrack;
	if (firstroom != "") waction += "&FirstRoomName="+firstroom;
	if (firstdate == "")
		firstdate = getFirstDate();
	if (firstdate != "") waction += "&FirstDate="+firstdate;
	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=5";
	if (CurrencyLabel != "") waction += "&CurrencyLabel="+CurrencyLabel;
	
	window.open(waction,"reservation","toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}
function mapwindow(url) {
	window.open(url, 'map', 'width=500,height=600,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}
function mapresultwindow(url) {
	window.open(url, '', 'width=600,height=600,menubar=yes,resizable=yes,scrollbars=yes,status=no,toolbar=yes');
}
function mapresultpopup() {
	//window.open('', 'map', 'width=850,height=500,toolbar=no,scrollbars=no,resizable=no');
	window.open('', 'map', 'width=500,height=600,toolbar=no,scrollbars=yes,resizable=yes');
	document.xmlMapForm.submit();
}



/*function DirectSearchZone()
{
	mainzone = document.idForm.mainzone.value;
	document.idForm.newzone.value = mainzone;
	document.idForm.submit();
}
*/

function SearchFromMap(zone)
{
	document.idForm.newzone.value = zone;
	document.idForm.submit();
}

function ChooseElmt()
{
	var submitform;
	codezone = document.idForm.region.value;
	name = codezone;
	if(name=="")
		name = "town";

	elmt = document.idForm.elements[name];
	elmtType = elmt.type;

	if(!elmtType)
		elmtType = elmt[0].type;

	//alert(elmtType);
	if(elmtType == "select-one") // si c'est un selecteur ...
	{
		menuNum = elmt.selectedIndex;
		codezone = elmt.options[menuNum].value;
		if(codezone)
			submitform = true;
	}
	else
	{
		
		if(elmt.length == undefined)
		{
			if(elmt.checked == true)
			{
				codezone = elmt.value;
				//alert(codezone);
				submitform = true;
			}
		}
		else
		{
			//alert(elmt.length);
			for (i=0;i<elmt.length;i++)
			{
				if(elmt[i].checked == true)
				{
					//alert(elmt[i]);
					codezone = elmt[i].value;
					//alert(codezone);
					submitform = true;
					break;
				}
			}
		}
	}
	if(submitform == true)
	{
		document.idForm.newzone.value = codezone;
		document.idForm.submit();
	}
	else
	{
		alert(StringError);
		return;
	}
}
// town list selected => launch search by town
function listTownSelected()
{	
	if(document.idForm.town)
	{		
		var menuNum = document.idForm.town.selectedIndex;
		var value = document.idForm.town.options[menuNum].value;
		var FirstChar = value.charAt(0);
		if (menuNum == null || FirstChar == "-")
		{
			alert(StringError);
			return;
		}
		else
			var val = document.idForm.town.options[menuNum].value;
		
		if (val == "")
		{
			alert("listTownSelected : missing value in <option>");
			return;
		}

		document.idForm.newzone.value = val;
		if(document.idForm.sort)
			document.idForm.sort.value = "";
		if(document.idForm.xmlrequest)
			document.idForm.xmlrequest.value = val;
	}
	else
	{
		mainzone = document.idForm.mainzone.value;
		document.idForm.newzone.value = mainzone;
	}
	document.idForm.submit();
}
/*
// for result search
function ChangePage(numpage)
{
	document.idForm.numpage.value = numpage;
	document.idForm.submit();
}
function ChangeSort(newSort)
{
	document.idForm.sort.value = newSort;
	document.idForm.numpage.value = 1;
	document.idForm.submit();
}
*/
function checkedSort()
{
	var emlt_checked = document.idForm.sort.value;
	var elmt_radio = document.formSort.radioSort;
	if(emlt_checked == "note")
		elmt_radio[0].checked=true;
	if(emlt_checked == "price")
		elmt_radio[1].checked=true;
	if(emlt_checked == "discount")
		elmt_radio[2].checked=true;
}
// for simple image
function ShowImage(img)
{
	var url = 'photos.phtml?img=' + img
	window.open(url, 'img', 'menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no');
	return false;
}
// ouvre la gallerie des images
function ShowPopup(DistNum)
{
	var url = 'photos.phtml?DistNum=' + DistNum + '&page=1';
	window.open(url,'','width=350,height=445,toolbar=no,scrollbars=no,resizable=no');
}
// ouvre les avis sur hotel
function ShowComments(DistNum)
{
	var url = 'http://portal.fastbooking-sa.fr/fiche/comments.phtml?DistNum=' + DistNum;
	window.open(url,'','width=700,height=550,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=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");
}

// pour le menu des satellites
function montre(id) {
var d = document.getElementById(id);
var NbMenu = 10;
	for (var i = 1; i<=NbMenu; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}
window.onload=montre;

function Xt_Stats_Quarter(zone)
{
	Xt_Id = document.idForm.XtId.value;
			if(Xt_Id == "")
			{
				document.idForm.XtId.value = 1;
				//xt_med('C','0', zone,'N');
				alert("Xiti : "+ zone);
			}
}

function getIdProperty(id, property) {
	var styleObject = document.getElementById( id );
	if (styleObject != null)
	{
		styleObject = styleObject.style;
		if (styleObject[property])
		{
			return styleObject[ property ];
		}
	}
	return null;
}

function setIdProperty( id, property, value )
{
	var styleObject = document.getElementById( id );
	if (styleObject != null)
	{
		styleObject = styleObject.style;
		styleObject[ property ] = value;
	}
}

function CollapseAll() {
	var title_str = document.idForm.hiddenzones.value;
	var elts = title_str.split("-");
	var ct = elts.length;
	
	for(i = 0; i < ct; i++) {
		elt_num = elts[i];
			if (getIdProperty(elt_num, "display") == "block")
			{
				setIdProperty(elt_num, "display", "none");
			}
	}
}


function ExpandElmt(ex) {
		if(getIdProperty(ex, "display") != "block")
		{
			setIdProperty(ex, "display", "block");
		}
}

function CollElmt(ex) {
		if(getIdProperty(ex, "display") != "none")
		{
			setIdProperty(ex, "display", "none");
		}
}

function Expand(ex) {
		if (getIdProperty(ex, "display") != "block" )
		{
			setIdProperty(ex, "display", "block");
			if(ex != "divthree" && ex != "search" && ex != "divbtn" && ex != "container2")
				document.idForm.region.value = ex;
				//alert(ex);
			setIdProperty("divthree", "display", "block");
			setIdProperty("search", "display", "block");
			setIdProperty("container2", "display", "block");
		}
}

function ExpColl(ex, coll)
{
	if(coll)
	{
		if (getIdProperty(coll, "display") == "block" )
			setIdProperty(coll, "display", "none");
	}
	if (getIdProperty(ex, "display") != "block")
		setIdProperty(ex, "display", "block");
	else
		setIdProperty(ex, "display", "none");
}

function goback()
{
	document.location.href = document.referrer;
}

// liens de la carte flash
function FromMapShowPage(city)
{
	nbvalue = MapUrl.length;
	if(nbvalue>0)
	{
		for(var i = 0; i < nbvalue; i+=2)
		{
			if(MapUrl[i] == city)
			{
				key = i+1;
				url = MapUrl[key];
		/*
				if(document.idForm)
				{			
					var vdate = veriformdate();

					d = vdate[0];
					m = vdate[1];
					y = vdate[2];
					night = vdate[3];
					adult = vdate[4];
					child = vdate[5];
					currency = vdate[6];
											
					querystring = "?day="+d;
					querystring+= "&month="+m;
					querystring+= "&year="+y;
					querystring+= "&nbdays="+night;
					querystring+= "&nbadult="+adult;
					querystring+= "&nbchild="+child;
					querystring+= "&currency="+currency;
					
					if(querystring != "")
						url+=querystring;
				}
				*/			
				//alert(url);
	    		document.location = url;
	    		return;
			}
	   }
	}
	alert("FromMapShowPage : no city " + city);
}

function veriformdate()
{
	var string_date = $F('fromdate').split("-");
	var d = string_date[2];
	var m = string_date[1];
	var y = string_date[0];

	var night = $F('nbdays');
	var adult = $F('nbadult');
	var child = $F('nbchild');
	var currency = $F('currency');
	
	
	/*
	var d = document.idForm.day.options[document.idForm.day.selectedIndex].value;
	var m = document.idForm.month.options[document.idForm.month.selectedIndex].value;
	var y = document.idForm.year.options[document.idForm.year.selectedIndex].value;
	var night = document.idForm.nbdays.options[document.idForm.nbdays.selectedIndex].value;
	var adult = document.idForm.nbadult.options[document.idForm.nbadult.selectedIndex].value;
	var child = document.idForm.nbchild.options[document.idForm.nbchild.selectedIndex].value;
	var currency = document.idForm.currency.options[document.idForm.currency.selectedIndex].value;
	
	var today = new Date();
	var tday = today.getDate();
	var tmonth = today.getMonth();
	var tyear = today.getFullYear();
	
	var ttime = Date.UTC(tyear, tmonth, tday); // nombre de millièmes de secondes jusqu'à ajdh
	var rtime = Date.UTC(y, (m-1), d); // nombre de millièmes de secondes  pour request date
	
	if(parseInt(rtime) < parseInt(ttime))
	{
		return false;
	}
	*/
	return new Array(d, m, y, night, adult, child, currency);
}


function ShowPage(page)
{
	/*
	var vdate = veriformdate();

	d = vdate[0];
	m = vdate[1];
	y = vdate[2];
	night = vdate[3];
	adult = vdate[4];
	child = vdate[5];
	currency = vdate[6];
	*/
	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 mapG(url) {
	window.open(url, 'map', 'width=600,height=500,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}

function printPage(host, page)
{
	var url;
	
	url = host;
	if(page)
		url+="/"+page+".htm";
	
	location.href=url;
}

function bubble_pos(obj) {
		this.x = 2;
		this.y = -100;
		if(obj) {
			//obj
			if (obj.offsetParent)
			{
				this.x += obj.offsetLeft;
				this.y += obj.offsetTop;

				while (obj = obj.offsetParent)
				{
					this.x += obj.offsetLeft;
					this.y += obj.offsetTop;
				}
			}
		}
	}
	
function show_bubble_info()
{
	var img_info = document.getElementById("img_bubble_info");
	var a_point = new bubble_pos(img_info);

	setIdProperty("bubble_info", "top", a_point.y + "px");
	setIdProperty("bubble_info", "left", a_point.x + img_info.width + "px");
	
	if(getIdProperty("bubble_info", "display") != "block")
			setIdProperty("bubble_info", "display", "block");
}
