   var targetLocation="Benrodestr. 125,Duesseldorf";
   var startLocation=null;
   var map=null;
   var directions;
   var directionsPanel;

   function setStartLocation(start)
   {
      startLocation=start;
   }

   function getStartLocation()
   {
      return startLocation;
   }


    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        directionsPanel = document.getElementById("map_text");
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        directions = new GDirections(map, directionsPanel);         
        GEvent.addListener(directions, "error", handleErrors);
        
        form = document.getElementById("map_fromAddress");
        if ( typeof startLocation!='string'  || startLocation==null )
        {        
          form.value="";
        } else {
          form.value=startLocation;
        }
         
              
        if ( typeof startLocation=="undefined" || startLocation==null )
        {
           loadAddress(targetLocation);
        } else
        {
           loadDirections()
        }        
      } else {
        document.write("<b>Der Stadtplan zur Praxis kann nicht angezeigt werden, da Ihr Internet-Browser nicht mehr aktuell ist oder die Option 'Javascript' deaktiviert wurde.</b>");
      }
    }
        
    function loadAddress(address) {
     var geocoder = new GClientGeocoder();
           
     geocoder.getLatLng(address,
      function(point) {
      if (!point) {
        alert("Die Adresse ist nicht auffindbar: "+address);
      } else {
        map.setCenter(point, 13);
        var marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml("<b>Ergotherapiepraxis Benrath</b><br/>Benrodestr. 125<br/>40597 D&uuml;sseldorf<br/><b>Tel: 0211 / 7 100 992</b>");
      }
    }
  );
  }
        
  function loadDirections() {
      directions.load("from: "+startLocation+" to: "+targetLocation, {"locale": "DE_de"});        
  }

  
  
   function handleErrors(){
	   if (directions.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("Eine geographische Lokalisierung konnte fuer die angegebene Adresse nicht vorgenommen werden. Die Ursache kann darin bestehen, dass die Adresse neu oder nicht korrekt ist.\nError code: " + directions.getStatus().code);
	   else if (directions.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("Die Ermittelung der geographischen Route konnte aufgrund einer nicht bekannten Ursache durchgefuehrt werden.\n Error code: " + directions.getStatus().code);
	   
	   else if (directions.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: " + directions.getStatus().code);

	   else if (directions.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: " + directions.getStatus().code);

	   else if (directions.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("A directions request could not be successfully parsed.\n Error code: " + directions.getStatus().code);
	    
	   else alert("Die Ermittelung der geographischen Route konnte aufgrund einer nicht bekannten Ursache durchgefuehrt werden.\n");
	   
	}
  
