var map;
    var gdir;
    var geocoder = null;
    var addressMarker;

    function load() {
      if (GBrowserIsCompatible()) {      
        map = new GMap2(document.getElementById("map"));

        gdir = new GDirections(map, document.getElementById("directions"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);

		map.setCenter(new GLatLng(52.292222, 4.841546), 13);
		map.addOverlay(new GMarker(new GLatLng(52.292222, 4.841546)));
        //setDirections("kanaalstraat, amsterdam", "Noorddammerlaan 24, Amstelveen", "en_US");
      }
    }
    
    function setDirections(fromAddress) {
      gdir.load("from: " + fromAddress + ", netherlands" + " to: Noorddammerlaan 24, Amstelveen, netherlands",
                { "locale": 'NL_nl' });
    }

    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("Er kon geen geografische locatie gevonden worden voor het opgegeven adres. Dit kan zijn omdat het adres niet klopt of omdat het een relatief nieuw adres betreft.\nGebruik de volgende synstax om een adres in te voeren: STRAAT, PLAATSNAAM.");
	   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("Er is geen geldig adres ingevoerd.\nGebruik de volgende synstax om een adres in te voeren: STRAAT, PLAATSNAAM");

	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\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(){ 
          
	}

