// JavaScript für Google-API
    var map;
    var gdir;
    var geocoder = null;
    var addressMarker;

    function googleMap_initialize() {
      if (GBrowserIsCompatible()) {      
        map = new GMap2(document.getElementById("map_canvas"));
		
		/** 
		* G_NORMAL_MAP- the default view
		* G_SATELLITE_MAP - showing Google Earth satellite images
		* G_HYBRID_MAP - showing a mixture of normal and satellite views
		* G_DEFAULT_MAP_TYPES - an array of these three types, useful for iterative processing
		**/

    gdir = new GDirections(map, document.getElementById("directions"));
    GEvent.addListener(gdir, "load", onGDirectionsLoad);
    GEvent.addListener(gdir, "error", handleErrors);
		map.addControl(new GLargeMapControl());
		map.addControl(new GOverviewMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(gd_GLatLng_X, gd_GLatLng_Y), gi_GLatLng_Zoom);
		map.setMapType(G_HYBRID_MAP);
		
		var point = new GLatLng(gd_GLatLng_X, gd_GLatLng_Y);
		var title = gs_title;
		var msg = gs_msg;
		map.addOverlay(createMarker(point, 1,title, msg));
      }
    }
	function createMarker(point, number, title, msg) {
	  var marker = new GMarker(point);
	  marker.value = number;
	  GEvent.addListener(marker, "click", function() {
		var myHtml = "<font style=\"color:#000000;\"><b>" + title + "</b><br/><br/>" + msg +"</font>";
		map.openInfoWindowHtml(point, myHtml);
	  });
	  return marker;
	}

    
    function setDirections(fromAddress, toAddress, locale) {
	 if(fromAddress == ""){
		showMessage("Bitte geben Sie eine Adresse an!" );
		return;
	  }
	  map.setMapType(G_NORMAL_MAP);
	  //resetCenterBox();	  
	  //alert("from: " + fromAddress + " to: " + toAddress + " locale: " +locale);
      gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
	  
    }

    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     showMessage("Adresse konnte nicht gefunden werden.");
	   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     showMessage("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_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)
	     showMessage("Der übergebene Schlüssel ist ungültig oder gehört nicht der richtigen Domain an. \n Error code: " + gdir.getStatus().code);

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST || gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     showMessage("Die eingegebene Adresse ist ungültig.\n Error code: " + gdir.getStatus().code);
	 
	   else showMessage("Unbekannter Fehler.");
	   
	}

	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...
	}
