  var map;
  var gdir;
  var geocoder = null;
  var addressMarker;
  var address;
  var coordinates;
  var i;
  var coords;
  var coord;
  var tabs = Array();
  function load() {
    if (GBrowserIsCompatible()) {
      
      document.forms.gmap.from.focus();
      map = new GMap2(document.getElementById("google_map"));
      

      gdir = new GDirections(map, document.getElementById("directions"));
      GEvent.addListener(gdir, "load", onGDirectionsLoad);
      GEvent.addListener(gdir, "error", handleErrors);
      
      //Koordinaten holen
      coords = getCoordinates();
      var coordarray = Array();
      //Koordinaten in x und y werte zerlegen und in Array schreiben
      for(i=0 ; i < coords.length; i++ ){
        coord = coords[i].split(",")
        coordarray[i] = new Array();
        for(j=0 ; j < 2; j++ ){
          coordarray[i][j] = coord[j];
        }
      }
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.addControl(new GScaleControl());
      map.addControl(new GOverviewMapControl(new GSize(150, 150)));
      
      //Setzt Zentrierten Startwert der Karte
      map.setCenter(new GLatLng(coordarray[0][0], coordarray[0][1]), 11);
      
      //Addresse holen
      address = getAddress();
      
      //Bilder holen
      pics = getPics();
      
      //Marker Feld Text zb.: Adresse, Ort, Tel. Nr, E-Mail...
      var tabContentAdress = Array();
      var anz = Array();
      for(i=0 ; i < coordarray.length; i++ ){
        marker = new GMarker(new GLatLng(coordarray[i][0], coordarray[i][1]));
        map.addOverlay(marker);
        
        tabContentAdress = "<div class=\"gmap_info_window\"><div id=\"address\">"+address[i]+ "<br><img src='"+pics[i]+"' alt='Bild' /></div></div>";
        tabs = [
        new GInfoWindowTab("Adresse", tabContentAdress)
        ];
        
        addMarkerWindow(GEvent, marker, "click", tabs);
      }
    }
  }
  
  //Ausgabe der Textblasen zu den entsprechenden markern beim daraufklicken
  function addMarkerWindow(GEvent, marker, event, tabs) {
    GEvent.addListener(marker, event, function() {
      marker.openInfoWindowTabsHtml(tabs);
    });
  }
  //Route berechnen + einzeichen in Karte
  function setDirections(fromAddress, toAddress, locale) {
    if (fromAddress == "") {
      alert("Bitte geben Sie eine Start-Adresse ein!");
      document.forms.gmap.from.focus();
      return;
    }
    document.getElementById("directions").innerHTML = "";
    gdir.load("from: " + fromAddress + " to: " + toAddress,
              { "locale": locale });
  }
  
  function handleErrors(){
   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
     alert("Die Start-Adresse konnte nicht zugeordnet werden. Bitte ergänzen Sie die Adresse um Informationen wie Strasse, PLZ oder Ort");
   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("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)
     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(){ 
     
	}
	
	function getDescription() {
	  var route = gdir.getRoute(0);
	  var descr = "";
	  
	  for (var i = 0; i < route.getNumSteps(); i++) {
	    step   = route.getStep(i);
	    descr += "<li>" + step.getDescriptionHtml() + "</li>";
	  }
	  return "<ol>" + descr + "<ol>";
	}
	