    //<![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 toggleGroup(type) {
      for (var i = 0; i < markerGroups[type].length; i++) {
        var marker = markerGroups[type][i];
        if (marker.isHidden()) {
          marker.show();
        } else {
          marker.hide();
        }
      } 
    }			  
			  
	function decodeStr(chaine) {
		chaine = chaine.replace(/&#128;/g, '€');		
		chaine = chaine.replace(/&#139;/g, '<');
		chaine = chaine.replace(/&#155;/g, '>');
		return chaine;
	}

    var icone_amateur = new GIcon();
    icone_amateur.image = "http://www.photographierlabretagne.com/images/icon2-14.png"; 
    icone_amateur.shadow = "http://www.photographierlabretagne.com/images/icon2-14s.png";
	icone_amateur.iconSize = new GSize(32, 32);
	icone_amateur.shadowSize = new GSize(59, 32);
	icone_amateur.iconAnchor = new GPoint(6, 24);
	icone_amateur.infoWindowAnchor = new GPoint(5, 1);	
	
	var icone_pro = new GIcon();
    icone_pro.image = "http://www.photographierlabretagne.com/images/icon2-14_pro.png"; 
    icone_pro.shadow = "http://www.photographierlabretagne.com/images/icon2-14s.png";
	icone_pro.iconSize = new GSize(32, 32);
	icone_pro.shadowSize = new GSize(59, 32);
	icone_pro.iconAnchor = new GPoint(6, 24);
	icone_pro.infoWindowAnchor = new GPoint(5, 1);	
	
	var customIcons = [];
    customIcons["amateur"] = icone_amateur;
    customIcons["pro"] = icone_pro;
	var markerGroups = { "amateur": [], "pro": []};
	
	// 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", "genMarkersAnnuaire.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());
			//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 photographe = markers[i].getAttribute("photographe");
				var ville = markers[i].getAttribute("ville");
				var miniature = markers[i].getAttribute("miniature");
				var description = decodeStr(markers[i].getAttribute("description"));
				var titre = decodeStr(markers[i].getAttribute("titre"));
				var url = markers[i].getAttribute("url");
				var professionnel = markers[i].getAttribute("professionnel");
				/*
				if(professionnel == "1") {
					professionnel = "professionnel";
				}else{
					professionnel = "amateur";
				}
				*/
				var email = markers[i].getAttribute("email");	

				var point = new GLatLng(parseFloat(markers[i].getAttribute("latitude")),
										parseFloat(markers[i].getAttribute("longitude")));
				var nomMarker =  markers[i].getAttribute("photographe"); 
				var marker = createMarker(point, photographe, ville, miniature, description, titre, url, professionnel, email, nomMarker);
				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 == "photographe_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, photographe, ville, miniature, description, titre, url, professionnel, email, nomMarker) {

		var type = "";
		if(professionnel == '1') {
			type  = "pro";		
        	//var marker = new GMarker(point, icone_pro);
		}else{
			type = "amateur";
			//var marker = new GMarker(point, icone_amateur);
		}
		var marker = new GMarker(point, customIcons[type]);
      	markerGroups[type].push(marker);

		var strPhotographe1 = "<table width='350' border=0 cellspacing=0 cellpadding=0>";
		if(miniature == '') {
			strPhotographe1 += "<tr><td width='1' valign='top'><img align='left' src='documents/clubs/espace.gif' border=0 class=imgInfoWindow></td>";
		}else{
			strPhotographe1 += "<tr><td width='100' valign='top'><a href='"+url+"' target='_blank'><img align='left' src='documents/annuaire/"+miniature+"' border='0' class='imgInfoWindow'></a></td>";
		}
		strPhotographe1 += "<td width='5'><img src='images/blank.gif' width='5'></td>";
		strPhotographe1 += "<td width='250' align='left' class='description'><span class='linkretour'>"+photographe+"</span><br/>";
		strPhotographe1 += ville + "<br/><br/>";
		strPhotographe1 += "<b>"+titre+"</b><br/>" + description;
		if(url != '') {
			strPhotographe1 += "<br/><br/><a href='"+url+"' target='_blank'>"+url+"</a>";
		}
		strPhotographe1 += "</td></tr>";
		strPhotographe1 += "</table>";	  
	  

	  
      GEvent.addListener(marker, 'click', function() {
        //if(activites != '') {
		//	var infoTabs = [new GInfoWindowTab("Club",strClub1),new GInfoWindowTab("Activités", strClub2),new GInfoWindowTab("Infos", strClub3)];
		//}else{
			var infoTabs = [new GInfoWindowTab("Club",strPhotographe1)];	//,new GInfoWindowTab("Infos", strClub3)];
		//}	
		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');
		}
    }		
    //]]>

