    var map;
    var geocoder;
    var gdir;
    var addressMarker;


    function initialize() {
      map = new GMap2(document.getElementById("map_canvas"));

      map.setCenter(new GLatLng(34, 0), 10);
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      geocoder = new GClientGeocoder();

	  var mt = map.getMapTypes();
		for (var i=0; i<mt.length; i++)
		{
//				mt[i].getMinimumResolution = function() {return 7;}
				mt[i].getMaximumResolution = function() {return 13;}

		}
    }

    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("CARTE DE POSITIONNEMENT NON DISPONIBLE");
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
        map.addOverlay(marker);
		map.setCenter(point, 10);
        marker.openInfoWindowHtml(/*place.address + */"<br>Attention l'emplacement marqu&eacute; n'est pas toujours,<br /> pr&eacute;cis&eacute;ment celui du bien,<br /> mais de la commune sur laquelle il se trouve");
  
       // marker.openInfoWindowHtml(place.address + "<br><br><form name=\"destination\">Y aller depuis cette adresse : <input id=\"from\" name=\"from\" type=\"text\"><input type=\"submit\" value=\"gO\" onclick=\"document.getElementById('map_canvas').style.width='350px';document.getElementById('directions').style.display='block';trajet(destination.from.value,'" + place.address +"')\"></form>");
      }
    }

    function voirlacarte(address) {
      geocoder.getLocations(address, addAddressToMap);
    }


    function trajet(from,to) {
      if (GBrowserIsCompatible()) {      
        map = new GMap2(document.getElementById("map_canvas"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        gdir = new GDirections(map, document.getElementById("directions"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);
        gdir.load("from: " + from + " to: " + to,{ "locale": "fr" });
      }
    }
    

    function handleErrors(){
                   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
                     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
                   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
                     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
                   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
                     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
                   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
                     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
                   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
                     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
                   else alert("An unknown error occurred.");
                }
                function onGDirectionsLoad(){ 
                }
                         
    google.load("language", "1");

    function traduit(div,lang) {
      var text = document.getElementById(div).innerHTML;
      google.language.detect(text, function(result) {
        if (!result.error && result.language) {
          google.language.translate(text, result.language, lang,
                                    function(result) {
            var translated = document.getElementById(div);
            if (result.translation) {
              translated.innerHTML = result.translation;
            }
          });
        }
      });
    }


