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

    function initialize() {
    }
    
    function setDirections(fromAddress, toAddress, locale) {
      if(typeof(map) == "undefined"){
          if (GBrowserIsCompatible()) {      
            map = new GMap2(document.getElementById("map_canvas"));
            map.addControl(new GSmallMapControl());
            map.addControl(new GMapTypeControl());
            gdir = new GDirections(map, document.getElementById("directions"));
            GEvent.addListener(gdir, "load", onGDirectionsLoad);
            GEvent.addListener(gdir, "error", handleErrors);

          }
      }
      gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
    }
    function setDirections2(fromAddress, toAddress, locale) {
      if(typeof(map) == "undefined"){
          if (GBrowserIsCompatible()) {     
            map = new GMap2(document.getElementById("map_canvas"));
            map.addControl(new GSmallMapControl());
            map.addControl(new GMapTypeControl());
            GEvent.addListener(gdir, "error", handleErrors);
            }
        }
    }
    function setDirections3(fromAddress, toAddress, locale) {
      if(typeof(map) == "undefined"){
          if (GBrowserIsCompatible()) {      
            map = new GMap2(document.getElementById("map_canvas"),{size:new GSize(0,0)});
            gdir = new GDirections(map, document.getElementById("directions"));
            GEvent.addListener(gdir, "load", onGDirectionsLoad);
            GEvent.addListener(gdir, "error", handleErrors);
          }
        }
      gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
    }

    function handleErrors(){
       if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
         alert("Zu Ihrer Anfrage konnte kein eindeutiger Ort bestimmt werden. Entweder existiert der Ort nicht, oder mehrere Orte mit dem gleichen Namen. geben Sie evtl. eine Postleitzahl mit an.");
       else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
         alert("Bitte geben Sie einen Start und einen Zielort ein.");
       
       else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
         alert("Bitte geben Sie einen Start und einen Zielort ein.");

    //   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 alert("Ein unbekannter Fehler ist aufgetreten.");
       
    }
    function onGDirectionsLoad(){ 
    }

