if (window.top.location!=window.location && window.top.location.indexOf("analytics")>0) {
	window.top.location=window.location;
}
function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
	( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
	( ( path ) ? ';path=' + path : '' ) +
	( ( domain ) ? ';domain=' + domain : '' ) +
	( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
	( ( path ) ? ';path=' + path : '') +
	( ( domain ) ? ';domain=' + domain : '' ) +
	';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

function getPubs (params)
{
	var url = '/ajax/links.php?a=1';
	if ((typeof geoip_country_code == 'function') && (country = geoip_country_code())) {
		url=url+'&country='+country;
	}
	if ((typeof geoip_city == 'function') && (city = geoip_city())) {
		url=url+'&city='+city;
	}
	if (params.idPays) {
		url=url+'&idPays='+params.idPays;
	}
	if (params.idVille) {
		url=url+'&idVille='+params.idVille;
	}
	if (params.lang) {
		url=url+'&lang='+params.lang;
	}

	if ($('linksZone')) {
		new Ajax.Updater('linksZone', url, {evalScripts:1 });
	}

}

// Gestion des promos
var tDataPromo;
var tZonesPromo;
tDataPromo = new Array();
tZonesPromo = new Array();
var initShowPromo=false;
function getPromo (idHotel)
{
	if (!$('zonepromo'+idHotel)) {
		document.write('<span id="zonepromo'+idHotel+'"></span>');
		tZonesPromo[tZonesPromo.length] = idHotel;
	}
}
function initPromos ()
{
	nbPromos = tZonesPromo.length;
	req="0";
	for (var i=0; i<nbPromos; i++) {
		req+=","+tZonesPromo[i];
	}
	if (!req) return false;
	var url = "/ajax/getPromo.php?idHotel="+req;

	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(transport) {
			//alert(url)
			//alert(transport.responseXML);
			promos = transport.responseXML.getElementsByTagName("promo");
			for (var i=0; i<promos.length; i++) {
				$("zonepromo"+promos[i].getAttribute("idHotel")).innerHTML=promos[i].firstChild.nodeValue;
				if (initShowPromo) $("promo"+promos[i].getAttribute("idHotel")).style.display="block";
			}
			
		}
	});

	//alert(url);

}
addEvent(window, 'load', function () { initPromos(); });