	/*var map = null;
    var geocoder = null;
*/

	function ucfirst(str) {
	   return str.substr(0,1).toUpperCase()+str.substr(1)
	}

    function initializeAPI() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(46.845164,3.164063), 5);
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        geocoder = new GClientGeocoder();
        var bounds = new GLatLngBounds();
      }
    }

    function finishAPI() {
        map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
        /*
        var zoomLevel = map.getBoundsZoomLevel(bounds);
        map.setZoom(zoomLevel);
        var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) / 2;
        var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) / 2;
        map.setCenter(new GLatLng(clat, clng));
        */
    }

    function AddAddressAPI(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              //map.setCenter(point, 6);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              //extending the boundaries
              bounds.extend(point);
              /* Lorsque le marqueur est cliqué, on ouvre l'info-bulle */
              GEvent.addListener(marker, "click", function() {
                  marker.openInfoWindowHtml(address);
                  //map.setCenter(point);
              });
            }
          }
        );
      }
    }
    
	function AddAddressAPI_LL(la,li,address) {
        var point = new GLatLng(la,li);
		var marker = new GMarker(point);
        map.addOverlay(marker);
        //extending the boundaries
        bounds.extend(point);
        /* Lorsque le marqueur est cliqué, on ouvre l'info-bulle */
        GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml(address);
            //map.setCenter(point);
        });
		geocoder = new GClientGeocoder();
    }
    
    function showAddressAPI(address,serveur,ou,titre,contenu) {
		var MonIcon = new GIcon(); 
		MonIcon.image = "http://"+serveur+"/templates/3/garage_photos/_ggmap_picto.png";
		MonIcon.shadow  = "http://"+serveur+"/templates/3/garage_photos/_ggmap_picto_shadow.png";
		MonIcon.iconSize = new GSize(27,39);
		MonIcon.shadowSize  = new GSize(34,34);
		MonIcon.iconAnchor = new GPoint(27, 39);
		MonIcon.infoWindowAnchor = new GPoint(10, 1);
		var markerOptions = {
			icon: MonIcon
		};

	
		map = new GMap2(document.getElementById("map_canvas"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
		geocoder = new GClientGeocoder();
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 12);
              var marker = new GMarker(point,markerOptions);
              map.addOverlay(marker);
			  
			  if(ou=='dep'){
				var html="<table cellpadding='5' cellspacing='2' border='0' style='display:block;float:left;width:375px;color:#184A7F;'><tr><td rowspan='2' style='width:100px'><img src='http://"+serveur+"/templates/3/garage_photos/garage_default.gif' alt='' /></td><td style='font-weight:bold;font-size:13px'>"+ucfirst(address)+"</td></tr><tr><td>"+contenu+"</td></tr></table>";
			  }else{
				var html="<table cellpadding='5' cellspacing='2' border='0' style='display:block;float:left;width:375px;color:#184A7F;'><tr><td rowspan='2' style='width:100px'><img src='http://"+serveur+"/templates/3/garage_photos/garage_default.gif' alt='' /></td><td style='font-weight:bold;font-size:13px'>"+titre+"</td></tr><tr><td>"+contenu+"</td></tr></table>";
			  }
			  
              marker.openInfoWindowHtml(html);
            }
          }
        );
      }
    }
	
	function showAddressAPI_LL(la,li,address,serveur,ou,titre,contenu) {
		var MonIcon = new GIcon(); 
		MonIcon.image = "http://"+serveur+"/templates/3/garage_photos/_ggmap_picto.png";
		MonIcon.shadow  = "http://"+serveur+"/templates/3/garage_photos/_ggmap_picto_shadow.png";
		MonIcon.iconSize = new GSize(27,39);
		MonIcon.shadowSize  = new GSize(34,34);
		MonIcon.iconAnchor = new GPoint(27, 39);
		MonIcon.infoWindowAnchor = new GPoint(10, 1);
		var markerOptions = {
			icon: MonIcon
		};
	
		map = new GMap2(document.getElementById("map_canvas"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(la, li), 13);
		 
        var point = new GLatLng(la,li);
		var marker = new GMarker(point,markerOptions);
        map.addOverlay(marker);
		
		if(ou=='dep'){
			var html="<table cellpadding='5' cellspacing='2' border='0' style='display:block;float:left;width:375px;color:#184A7F;'><tr><td style='width:100px'><img src='http://"+serveur+"/templates/3/garage_photos/garage_default.gif' alt='' /></td><td style='font-weight:bold;font-size:13px'>"+ucfirst(address)+"</td></tr></table>";
		  }else{
			var html="<table cellpadding='5' cellspacing='2' border='0' style='display:block;float:left;width:375px;color:#184A7F;'><tr><td rowspan='2' style='width:100px'><img src='http://"+serveur+"/templates/3/garage_photos/garage_default.gif' alt='' /></td><td style='font-weight:bold;font-size:13px'>"+titre+"</td></tr><tr><td>"+contenu+"</td></tr></table>";
		  }
		
		marker.openInfoWindowHtml(html);

		 
		geocoder = new GClientGeocoder();
    }
