 var isIE6 = false, isIE7 = false,
 isFIREFOX2 = false, isFIREFOX = false,
 isNETSCAPE7 = false, isNETSCAPE = false,
 isOPERA9 = false, isOPERA = false,
 isUNKNOWN = false; 

var strChUserAgent = navigator.userAgent;
 var intSplitStart = strChUserAgent.indexOf("(",0);
 var intSplitEnd = strChUserAgent.indexOf(")",0);
 var strChStart = strChUserAgent.substring(0,intSplitStart);
 var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
 var strChEnd = strChUserAgent.substring(strChEnd);

 if(strChMid.indexOf("MSIE 7") != -1)
 isIE7 = true;
 else if(strChMid.indexOf("MSIE 6") != -1)
 isIE6 = true;
 else if(strChEnd.indexOf("Firefox/2") != -1)
 isFIREFOX2 = true;
 else if(strChEnd.indexOf("Firefox") != -1)
 isFIREFOX = true;
 else if(strChEnd.indexOf("Netscape/7") != -1)
 isNETSCAPE7 = true;
 else if(strChEnd.indexOf("Netscape") != -1)
 isNETSCAPE = true;
 else if(strChStart.indexOf("Opera/9") != -1)
 isOPERA9 = true;
 else if(strChStart.indexOf("Opera") != -1)
 isOPERA = true;
 else
 isUNKNOWN = true;
 
 
//ie 6 fix PNG 24
function setTransparency(img) {
	if (isIE6) {
		 var imgID = (img.id) ? "id='" + img.id + "' " : "" ;
         var imgClass = (img.className) ? "class='" + img.className + "' " : "" ;
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " ;
         var imgStyle = "display:inline-block;" + img.style.cssText ;
         if (img.align == "left") imgStyle = "float:left;" + imgStyle ; 
         if (img.align == "right") imgStyle = "float:right;" + imgStyle ; 
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle; 
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"  ;
         img.outerHTML = strNewHTML ;
	}
}


function gotoLink(prmId) {
	window.open(prmId,"_blank","menubar=yes,toolbar=yes,resizable=yes,status=yes,dependent=yes,location=yes,scrollbars=yes") ;
}

function EcrireCookie(nom, valeur) {
	var argv=EcrireCookie.arguments;
	var argc=EcrireCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=nom+"="+escape(valeur)+
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}


function LireCookie (name) {
	 if ( document.cookie) { // Le cookie est-il valide ?
			  index = document.cookie.indexOf( name);
			  if ( index != -1) {
					   nDeb = (document.cookie.indexOf( "=", index) + 1);
					   nFin = document.cookie.indexOf( ";", index);
					   if (nFin == -1) {nFin = document.cookie.length;}
					   return unescape(document.cookie.substring(nDeb, nFin));
			  }
	 }
	 return null;
}


function saveCommsProduit(id) {
	
	commentaire = document.commsForm.comms.value ;
	
	var expire = new Date();
	var dixMinutes = expire.getTime() + (10*60*1000);
	expire.setTime(dixMinutes);

	EcrireCookie("comm_" + id,commentaire,expire,"/") ;

}

function showMap(id_produit) {
	ajax = new Ajax(true) ;
	ajax.appendData('id_produit',id_produit) ;
	ajax.sendAndLoad("/ajax/map.php", "POST", showMapHandler) ;
}

function showMapHandler(conn) {
	eval(conn.responseText) ;	
}

function showMapMonument(id_monument) {
	ajax = new Ajax(true) ;
	ajax.appendData('id_monument',id_monument) ;
	ajax.sendAndLoad("/ajax/map.php", "POST", showMapHandler) ;
}


function hideMap() {
	document.getElementById('ggMap').style.display = "none" ;
	GUnload() ;
}

function mapGetTitle(id_produit) {
	ajax = new Ajax(true) ;
	ajax.appendData('id_produit',id_produit) ;
	ajax.sendAndLoad("/ajax/getHotelName.php", "POST", mapRefreshTitle) ;
}

function mapRefreshTitle(conn) {
	document.getElementById('mapTarget').firstChild.nodeValue = conn.responseText ;
}

function mapGetHotelInfos(id_produit) {
	ajax = new Ajax(true) ;
	ajax.appendData('id_produit',id_produit) ;
	ajax.sendAndLoad("/ajax/getHotelInfo.php", "POST", mapRefreshInfos) ;
}

function mapRefreshInfos(conn) {
	eval(conn.responseText) ;
}

function mapGetMonumentTitle(id_monument) {
	ajax = new Ajax(true) ;
	ajax.appendData('id_monument',id_monument) ;
	ajax.sendAndLoad("/ajax/getMonumentName.php", "POST", mapRefreshTitle) ;
}

function mapGetMonumentInfos(id_monument) {
	ajax = new Ajax(true) ;
	ajax.appendData('id_monument',id_monument) ;
	ajax.sendAndLoad("/ajax/getMonumentInfo.php", "POST", mapRefreshInfos) ;
}

function townAutoComplete(idProduit) {
	ajax = new Ajax(true) ;
	ajax.sendAndLoad("/ajax/hotelGetTown.php?id=" + idProduit,"GET",townAutoCompleteHandler) ;
}

function townAutoCompleteHandler(conn) {
	document.getElementById("lieuMEH").value = conn.responseText ;
}

//Ajouter aux favoris
function ajouterFavoris(titre) {
	if (String(titre) == "undefined") titre = document.title ;
	if (navigator.appName.indexOf("Explorer") > -1) { window.external.AddFavorite(location.href,unescape(titre)) ; }
	else { window.sidebar.addPanel(unescape(titre),location.href,"") ; }
}

function showDesc() {
	noeud = document.getElementById('descBtn') ;
	document.getElementById('descriptionRubrique').removeChild(noeud) ;
	document.getElementById('descleft').style.display = "inline";
	

}

function getScrollingPosition()
{
 var position = new Array(2) ;

 if (typeof window.pageYOffset != 'undefined')
 {
   position[0] = window.pageXOffset ;
   position[1] = window.pageYOffset ;
 }

 else if (typeof document.documentElement.scrollTop
     != 'undefined' && document.documentElement.scrollTop > 0)
 {
   
   position[0] = document.documentElement.scrollLeft ;
   position[1] = document.documentElement.scrollTop ;
 }

 else if (typeof document.body.scrollTop != 'undefined')
 {
 
   position[0] = document.body.scrollLeft ;
   position[1] = document.body.scrollTop ;

 }

 return position;
}

function showTextComment(produit){
	
text = "<h2>Donnez votre avis sur "+produit+" !</h2><br /><p>Donnez votre avis sur cet hôtel, sur la base des critères ci-dessous.<br />Cliquez simplement sur étoiles pour définir la note que vous souhaitez donner à cet hôtel.<br />Enfin, donnez en quelques mots votre avis sur l'hôtel !<br /><br /><small>NB : Tous les commentaires sont soumis à modération (ceux abrégés en SMS seront supprimés).<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ne vous inquiétez donc pas si ceux-ci ne s'affichent pas instantanément.</small></p><br /><br />";

document.write(text);

}
