    //<![CDATA[
	function addLoadEvent(laFonction) { 
        var oldonload = window.onload; 
        if (typeof window.onload != 'function'){ 
                window.onload = laFonction ;
        } else { 
                window.onload = function() { 
                        oldonload(); 
                        laFonction(); 
                } 
        } 
	} 			   
	
	addLoadEvent(loadMap);  //chargement de la carte sur le onload de la page
			   
	function decodeStr(chaine) {
		chaine = chaine.replace(/&#128;/g, '€');		
		chaine = chaine.replace(/&#139;/g, '<');
		chaine = chaine.replace(/&#155;/g, '>');
		return chaine;
	}

    //Création d´un icone personnalisé.
	var iconLieu = new GIcon();
	iconLieu.image = "http://maps.google.com/mapfiles/kml/pal4/icon46.png";
	iconLieu.shadow = "http://maps.google.com/mapfiles/kml/pal4/icon46s.png";
	iconLieu.iconSize = new GSize(20, 20);
	iconLieu.shadowSize = new GSize(20, 20);
	iconLieu.iconAnchor = new GPoint(6, 20);
	iconLieu.infoWindowAnchor = new GPoint(5, 1);	
	
	// arrays to hold copies of the markers and html used by the side_bar
	// because the function closure trick doesnt work there
	var gmarkers = [];
	var k = 0;	
		
    function loadMap() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));

	    // Read the data from location.xml 
        var request = GXmlHttp.create(); 
        request.open("GET", "genMarkersLieu.php", true); 
        request.onreadystatechange = function() { 
          if (request.readyState == 4) { 
			document.getElementById('waitImage').innerHTML = "";  //on cache l'image d'attente
			document.getElementById('map').style.visibility="visible";	//et on affiche la carte
			
		    map.addControl(new GSmallMapControl());
		   // map.addControl(new GMapTypeControl());
			
			//carte centrée de la Bretagne
			map.setCenter(new GLatLng(48.09275716032735, -3.087158203125), 8);
			
			// Autorise le double click permettant de zoomer
			map.enableDoubleClickZoom() ;
			//Zoom progressif 
			map.enableContinuousZoom(); 
		
			  var xmlDoc = request.responseXML; 
			  // obtain the array of markers and loop through it 
			  var markers = xmlDoc.documentElement.getElementsByTagName("marker");
			  for (var i = 0; i < markers.length; i++) {
				var lieu = markers[i].getAttribute("lieu");
				var groupePhoto = markers[i].getAttribute("groupePhoto");
				var description = decodeStr(markers[i].getAttribute("description"));
				var a_voir = decodeStr(markers[i].getAttribute("a_voir"));
				var conseils = decodeStr(markers[i].getAttribute("conseils"));
				var saison = decodeStr(markers[i].getAttribute("saison"));
				var autre = decodeStr(markers[i].getAttribute("autre"));
				var payant_txt = "";
				if(markers[i].getAttribute("payant") == "0") {
					payant_txt = "non";
				}else{
					if(markers[i].getAttribute("payant") == "1") { payant_txt = "oui (" + decodeStr(markers[i].getAttribute("payant_detail")) + ")"; }
					if(markers[i].getAttribute("payant") == "2") { payant_txt = "selon (" + decodeStr(markers[i].getAttribute("payant_detail")) + ")"; }
				}				
				var photos = markers[i].getAttribute("photos");
				var mot_cle = markers[i].getAttribute("mot_cle");
				var scriptVote = '';
				var auteur = markers[i].getAttribute("auteur");
				var auteur_email = markers[i].getAttribute("auteur_email");
				var auteur_url = markers[i].getAttribute("auteur_url");
				var point = new GLatLng(parseFloat(markers[i].getAttribute("latitude")),
										parseFloat(markers[i].getAttribute("longitude")));
				var marker = createMarker(point, lieu, description, a_voir, conseils, saison, autre, payant_txt, photos, mot_cle, scriptVote, auteur, auteur_email, auteur_url);
				map.addOverlay(marker);
			  }
       //});
	   
			  //décodage des paramètres passés en url pour afficher une info-bulle particulière
			  var query = window.location.search.substring(1); 
			  var pairs = query.split(","); 
			  for (var i=0; i<pairs.length; i++) { 
				  var pos = pairs[i].indexOf("="); 
				  var argname = pairs[i].substring(0,pos); 
				  var value = pairs[i].substring(pos+1); 
				  if (argname == "lieu_id") { 
					var mymarker = parseInt(unescape(value)); 
					myclick(mymarker); 
				  } 
			  } 
        } else{
			document.getElementById('waitImage').innerHTML = "<span class='titreBleu'><b>Veuillez patienter pendant le chargement de la carte...</b><br/><br/><img src='images/ajax-loader.gif'>";
			document.getElementById('map').style.visibility="hidden";
		}
      } 
      request.send(null); 
      }
    }

	function createMarker(point, lieu, description, a_voir, conseils, saison, autre, payant_txt, photos, mot_cle, scriptVote, auteur, auteur_email, auteur_url) {
	  var marker = new GMarker(point, iconLieu);

	  var photoUne = photos.split('#')[0];
	  var strLieu1 = "<table width='300' border=0 cellspacing=2 cellpadding=2><tr>";
	  if(photoUne != '') {
	  	strLieu1 += "<td><img align='left' src='http://www.atraverslobjectif.com/photos/" + photoUne + "' border=0 class='imgInfoWindow'></td>";
	  }
	  strLieu1 += "<td align='left' valign='top' width='300'><span class='linkretour'>"+ lieu + "</span><br>";
	  strLieu1 += scriptVote + "</td></tr>";
	  strLieu1 += "<tr><td colspan=2 width='300' align='left' class='descriptionBulle'>" + description;
	  if(auteur != '' && auteur != 'vero') {
			if(auteur_url != '') {
				strLieu1 += "<br><br>(<i>proposé par <b><a href='" + auteur_url + "' target='_blank'>" + auteur + "</a></b></i>)";
			}else{
				strLieu1 += "<br><br>(<i>proposé par <b><a href='mailto:" + auteur_email +"'>" + auteur + "</a></b></i>)";
			}
		}
	  strLieu1 += "</td></tr>";
	  strLieu1 += "</table>";
	
	  var cpt=0;
	  var strLieu2 = "<table width=300 border=0 cellspacing=0 cellpadding=0><tr><td class='linkretour' align='left'>" + lieu + "</td></tr></table><hr size=1 width=300 align=left><table width=300 border=0 cellspacing=5 cellpadding=0><tr>";
	  var tableau=photos.split('#');
	  for (var i=0; i<tableau.length; i++) {
		 //document.write("tableau[" + i + "] = " + tableau[i] + "<BR>");
		 cpt += 1;
		 if(cpt > 3) { 
		 	strLieu2 += "</tr><tr>";
			cpt=0;
		 } 
		 strLieu2 +=  "<td valign='middle' align='center' width='95'><a href='http://www.atraverslobjectif.com/photos/" + tableau[i].replace('.jpg','') + "_gde.jpg' class='highslide' onclick='return hs.expand(this);'><img src='http://www.atraverslobjectif.com/photos/"+tableau[i]+"' border=0 valign='middle'></a><img src='images/espace.gif' width=5 height=1></td>";
	  }
	  if(cpt < 3) { 
 		 strLieu2 += "<td width='95'>&nbsp;</td>";
	  }
	  strLieu2 += "</tr>";
	  strLieu2 += "<tr><td colspan=3></td></tr>";
	  if(mot_cle != '') {	
			strLieu2 += "<tr><td colspan=3 align='left'><a class='liensrubrique' href='http://www.atraverslobjectif.com/resultats.php?motCle="+mot_cle+"' target=\"_blank\">Voir d'autres photos</a></td></tr>";
	  }
	  strLieu2 += "</table>";
	  
	  var strLieu3 = "<table width=300 border=0 cellspacing=0 cellpadding=0><tr><td class='linkretour' align='left'>" + lieu + "</td></tr></table><hr size=1 width=300 align=left>";
	  strLieu3+= "<table width=300 border=0 cellspacing=5 cellpadding=0>";
	  strLieu3 += "<tr><td align='left' class='descriptionBulle'><a class='liensrubrique'>A voir</a> : " + a_voir + "</td></tr>";
	  strLieu3 += "<tr><td align='left' class='descriptionBulle'><a class='liensrubrique'>Conseils</a> : " + conseils + "</td></tr>";
	  strLieu3 += "<tr><td align='left' class='descriptionBulle'><a class='liensrubrique'>Saison idéale</a> : " + saison + "</td></tr>";
	  if(autre != '') {
	  	strLieu3 += "<tr><td align='left' class='descriptionBulle'><a class='liensrubrique'>Autre</a> : " + autre + "</td></tr>";
	  }
	  if(payant_txt != 'non') {
		strLieu3 += "<tr><td align='left' class='descriptionBulle'><a class='liensrubrique'>Payant</a> : " + payant_txt + "</td></tr>";
	  }
	  strLieu3 += "</table>";
	  
	  
	  GEvent.addListener(marker, 'click', function() {
		if(photos == '') {
			var infoTabs = [new GInfoWindowTab("Lieu",strLieu1),new GInfoWindowTab("Infos", strLieu3)];
		}else{
			var infoTabs = [new GInfoWindowTab("Lieu",strLieu1),new GInfoWindowTab("Photos", strLieu2),new GInfoWindowTab("Infos", strLieu3)];
		}
		marker.openInfoWindowTabsHtml(infoTabs);
		
	  });
	 
 	  // save the info we need to use later for the side_bar
      gmarkers[k] = marker;
	  k++; 
	  
	  return marker; 
	}
	
    // This function picks up the click and opens the corresponding info window
    function myclick(k) {
		if(gmarkers[k]) {
	  		GEvent.trigger(gmarkers[k], 'click');
		}
    }		
    //]]>
