      var map;
      var gdir;
      var geocoder = null;
      var addressMarker;
      function googleInitialize() {
        if (GBrowserIsCompatible()) {      
          map = new GMap2(document.getElementById("map_canvas"));
          var lip = new GLatLng(45.729843, 4.826860); // coordinate of LIP
	  var debourg = new GLatLng(45.73139520360288, 4.833544492721558); // coordinate of Debourg station
          var marker_lip = new GMarker(lip);
	  var marker_debourg = new GMarker(debourg);
// 	  var path1 = new GPolyline.fromEncoded({
// 		  color: "#0000ff",
// 		  weight: 4,
// 		  opacity: 0.8,
// 		  points: "svavGaqm\\wA}Cu@Sw@AIPs@@_@O}GIqAWIb@OPgAIqAE?Qq@I",
// 		  levels: "PBEAABAAC@C?BBP",
// 		  zoomFactor: 2,
// 		  numLevels: 18});
          gdir = new GDirections(map, document.getElementById("directions"));
          GEvent.addListener(gdir, "load", onGDirectionsLoad); <!-- Charge la partie pour les distances -->
          GEvent.addListener(gdir, "error", handleErrors); <!-- Charge la partie pour les messages d erreurs -->

	  // initialize map center
          map.setCenter(lip, 15);

	  // initialize controls
          map.addControl(new GMapTypeControl());
          map.addControl(new GLargeMapControl());
          map.addControl(new GScaleControl());

	  // zoom options
          map.enableScrollWheelZoom();
	  map.enablePinchToZoom();

	  //
          map.addOverlay(marker_lip);
          map.addOverlay(marker_debourg);
// 	  map.addOverlay(path1);
          map.setMapType(G_HYBRID_MAP);

	  // Pop ups
          var address_lip =""+
	    	"<img height=\"40\" src=\"images/newlogo_sss4_trans.png\" width=\"71\" alt=\"SSS\">"+
	    	"<img height=\"40\" src=\"images/logoENS.png\" width=\"71\" alt=\"ENS\"><br/><br/>"+
	        "<strong>SSS 2009</strong>, held in:<br/>" +
		"<a target=\"_blank\" href=\"http://www.ens-lyon.eu\">&Eacute;cole Normale Sup&eacute;rieure of Lyon</a><br />"+
		"46, All&eacute;e d'Italie<br/>" +
	        "69364 Lyon Cedex 07<br/>" +
	        "France<br/>" +
	        "Tel: +33 4 72 72 80 80 <br/><br/><br/><br/>";
	  GEvent.addListener(marker_lip, "click", function() {marker_lip.openInfoWindowHtml(address_lip);});

          var address_debourg =""+
	        "<strong>Debourg subway station</strong><br/>" +
	        "<a target=\"_blank\" href=\"http://www.tcl.fr/changeLanguage.asp?language=EN\">TCL</a><br/>";
	  GEvent.addListener(marker_debourg, "click", function() {marker_debourg.openInfoWindowHtml(address_debourg);});
         }
      }

      function setDirections(fromAddress, toAddress, locale, travel_mode) {
	  var tm;
	  tm = G_TRAVEL_MODE_DRIVING;
	  if (travel_mode == 0)
	      tm = G_TRAVEL_MODE_WALKING;
	  gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale,"travelMode": tm});
      }

      function handleErrors() {
        if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
          alert("Aucune location géographique correspondante n'a pu être trouvée pour l'une des adresses spécifiées.\nCe qui peut être du à une adresse récente, ou incorrecte.\nN'oubliez pas d'ajouter dans l'adresse le pays (en anglais).\nError code: " + gdir.getStatus().code);
        else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
          alert("La demande d'itinéraire n'a pu être calculée avec succès, aucune raison de l'échec n'est connu.\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("La clé (Key) n'est pas valide ou ne correspond pas au nom de domaine. \n Error code: " + gdir.getStatus().code);
        else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
          alert("La demande d'itinéraire n'a pu être correctement parsé.\n Error code: " + gdir.getStatus().code);
        else alert("Une erreur inconnue est survenue.");
      }

      var newMarkers = [];
      var latLngs = [];
      var icons = [];
	
      function onGDirectionsLoad() {
        var reg=new RegExp("&nbsp;", "g");
        kilometrage = gdir.getDistance().html;
        document.getElementById("km").value = kilometrage.replace(reg,' ');
      }

      //////////////////////////////////////////////////////////////////////
      // The add-on code for draggable markers
      // Esa 2008
      //

      var newMarkers = [];
      var latLngs = [];
      var icons = [];
	
      // Note the 'addoverlay' GEvent listener added inside initialize() function

      function onGDirectionsAddOverlay() {
	// Remove the draggable markers from previous function call.
	for (var i=0; i<newMarkers.length; i++) {
          map.removeOverlay(newMarkers[i]);
	}

	// Loop through the markers and create draggable copies
	for (var i=0; i<=gdir.getNumRoutes(); i++) {
          var originalMarker = gdir.getMarker(i);
          latLngs[i] = originalMarker.getLatLng();
          icons[i] = originalMarker.getIcon();
          newMarkers[i] = new GMarker(latLngs[i],{icon:icons[i], draggable:true});
          map.addOverlay(newMarkers[i]);

          // Get the new waypoints from the newMarkers array and call loadFromWaypoints by dragend
          GEvent.addListener(newMarkers[i], "dragend",
                             function() {
                               var points = [];
                               for (var i=0; i<newMarkers.length; i++) {
                                 points[i]= newMarkers[i].getLatLng();
                               }
		              gdir.loadFromWaypoints(points);
		             });

	  //Bind 'click' event to original hidden marker
	  copyClick(newMarkers[i],originalMarker);
		
          // hide or remove the original marker
	  //originalMarker.hide();
	  map.removeOverlay(originalMarker);
	}
		
        function copyClick(newMarker,oldMarker) {
          GEvent.addListener(newMarker, 'click',
                             function() {
                               GEvent.trigger(oldMarker,'click');
                             });
        }
       // End of draggable markers code
       // Esa 2008
       //////////////////////////////////////////////////////////////////
	}
