/**
librairie javascript pour l utilisation du javascript dynamique
*/

/**
renvoie le nom de la webapp en fonction du site
*/
function getWebapp(){
	var l_host = document.location.host;
	var l_webapp = "";
	if (l_host.indexOf("accorhotels")>-1)   {l_webapp="accorhotels";}
	else if (l_host.indexOf("sofitel")>-1)  {l_webapp="sofitel";}
	else if (l_host.indexOf("suite")>-1)    {l_webapp="suite";}
	else if (l_host.indexOf("novotel")>-1)  {l_webapp="novotel";}
	else if (l_host.indexOf("mercure")>-1)  {l_webapp="mercure";}
	else if (l_host.indexOf("adagio")>-1)  	{l_webapp="adagio";}
	else if (l_host.indexOf("mgallery")>-1)  {l_webapp="mgallery";}
	else if (l_host.indexOf("ibis")>-1)     {l_webapp="ibis";}
	else if (l_host.indexOf("etap")>-1)     {l_webapp="etaphotel";}
	else if (l_host.indexOf("formule1")>-1) {l_webapp="formule1";}
	else if (l_host.indexOf("hotelf1")>-1)  {l_webapp="hotelf1";}
	else if (l_host.indexOf("thalassa")>-1) {l_webapp="thalassa";}
	else if (l_host.indexOf("pullman")>-1)  {l_webapp="pullman";}
  else if (l_host.indexOf("all-seasons-hotels")>-1) {l_webapp="allseasons";}
	else {l_webapp="accorhotels";}
	return l_webapp;
}

/**
recupere la valeur du parametre p dans la querystring
s il y a plusieurs parametres p  ( ?p=1&p=2 ) c est la premiere valuer qui est renvoyee.
*/
function getParam(p) {
	var params = new Array();
	var infos = location.search.substring(1);
	params = infos.split("&");
	for (var i=0;i<params.length;i++) {
		var pos = params[i].indexOf("=");
		if (pos != -1 && p==params[i].substring(0,pos))
			return params[i].substring(pos+1);
	}
	return '';
}




function getXMLHttpObj(){
	if(typeof(XMLHttpRequest)!='undefined'){return new XMLHttpRequest();}
	var axO=['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'], i;
	for(i=0;i<axO.length;i++)
		try{return new ActiveXObject(axO[i]);}catch(e){}
	return null;
}

/**
charge le javascript pour le document en cours.
utiliser :
eval(loadJavascript("path/to/file.js"));
*/
function loadJavascript(jsurl){
	if (navigator.userAgent.indexOf("Opera")>-1) {
		document.write('<sc'+'ript type="text/javascript" src="'+jsurl+'"><\/scr'+'ipt>');
	} else {
		var oXML = getXMLHttpObj();
		oXML.open('GET', jsurl, false);
		oXML.send('');
		return oXML.responseText;
	}
}


/**
charge une feuille de style pour le document en cours.
*/
function loadCss(url){
	var l_head = document.getElementsByTagName("head")[0];
	var l_css = document.createElement('link');
	l_css.rel = "stylesheet";
	l_css.href = url;
	l_head.appendChild(l_css);
}

