
    function load() {
      if (GBrowserIsCompatible()) {      
        map = new GMap2(document.getElementById("map"));
		setupMap();
		map.enableScrollWheelZoom();
        gdir = new GDirections(map, document.getElementById("directions"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);
		
      }
    }
	
	function setupMap() {      
        
        geocoder = new GClientGeocoder();
        showAddress("Kieselbronner Str. 42, 75177 pforzheim");
               
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.setCenter(new GLatLng(48.913280, 8.723585), 10);
        map.enableDoubleClickZoom();
    }
	
	function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (point) {
              my_point = point;
              marker = new GMarker(point, { icon: get_icon() });
              map.addOverlay(marker);              
            }
          }
        );
      }
    }

    function get_icon() {
      
      var icon = new GIcon();
      icon.image = "files/ghenne.png";      
	  icon.iconSize = new GSize(64, 64); 	
      icon.iconAnchor = new GPoint(32, 40);
      icon.infoWindowAnchor = new GPoint(32, 0);                  
      return icon;
    }
	
	
    function setDirections(fromAddress) {
		document.getElementById("msg").className = '';
		document.getElementById("msg").innerHTML = '';
		map.removeOverlay(marker);
		gdir.load("from: " + fromAddress + " to: " + "Kieselbronner Str. 42, 75177 pforzheim", { "locale": "de" });
    }

    function handleErrors(){
		/*
		if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
			err_str = "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)
			err_str = "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)
			err_str = "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)
			err_str = "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)
			err_str = "A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code;
		else err_str = "An unknown error occurred.";
		*/
		document.getElementById("msg").className = 'anfahrt_err';
		document.getElementById("msg").innerHTML = 'Bei Ihrer Anfrage ist ein Fehler aufgetreten. Bitte überprüfen Sie Ihre Eingabe.';
		map.addOverlay(marker);         
		//alert('hallo welt'); //.innerHTML = "error";
	   
	}

	function onGDirectionsLoad(){ 
          // Use this function to access information about the latest load()
          // results.

          // e.g.
			// document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
			// and yada yada yada...
	}
