function map_init()
{
	//alert('in func map_init');
	
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("div1"));
        map.setCenter(new GLatLng(51.877, 6.155), 16); 
        
        map.addControl(new GSmallZoomControl());
        map.addControl(new GMapTypeControl());
        map.setMapType(G_HYBRID_MAP);
        
        var mapScale = new GScaleControl();
        var lowLeft = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(2,2));     
        map.addControl(mapScale, lowLeft);       
        
        
        
        gdir = new GDirections(map, document.getElementById("div2"));
        GEvent.addListener(gdir, "error", handleErrors); 
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        
      }
   } 	


// ---------------------------------------------------
	
 function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("Eine entsprechende geografische Adresse wurde nicht gefunden.\n Die Adresse könnte relativ neu sein, oder es könnte ein Schreibfehler vorliegen.\nError code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("Die Berechnungsanfrage konnte nicht verarbeitet werden. Eine genauere Beschreibung des Fehlers ist nicht möglich.\n Error code: " + gdir.getStatus().code);
	   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("Ein HTTP q Parameter fehlt oder hat keinen Inhalt. Für Geo-Anfragen bedeutet das, die Angabe war leer. Bei Routenanfragen ist wohl keine Anforderung erfolgt.\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("Der geo-Code für die genannte Adresse bzw. Route kann aus legalen GrÃ¼nden nicht angezeigt werden.\n Error code: " + gdir.getStatus().code);
	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	     alert("Der Google-Key enspricht nicht der Domäne, für die er ausgegeben wurde. \n Error code: " + gdir.getStatus().code);

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("Eine Routenanfrage konnte nicht entsprechend verarbeitet werden.\n Error code: " + gdir.getStatus().code);
	    
	   else alert("Ein unbekannter Fehler ist aufgetreten.");
	   
	}
// ---------------------------------------------------
	  function onGDirectionsLoad(){ 
      // Use this function to access information about the latest load()
      // results.

      // e.g.
      // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  map.setMapType(G_NORMAL_MAP);
	}
	

  
// ---------------------------------------------------
 function setDirections(fromAddress, toAddress, loc) {
 	//alert('in setDirections');

   //   alert(toAddress);
      gdir.load("from: " +fromAddress + " to: " + toAddress,
                { "locale": loc });

    }


// ---------------------------------------------------

function displayForm1()
{
document.getElementById("div2").innerHTML = '<form action="#" class="w" onsubmit="setDirections(this.from.value, this.to.value, this.loc.value); return false"> '
																					 +'Routenplanung f&uuml;r Anreise aus '
																					 +' <input type="text" size="20" id="fromAddress" name="from"  value="Gelderner Straße, Xanten, DE"> '
 																					 +' <input type="hidden" size="20" id="toAddress" name="to"  value="46446 Emmerich, Europastraße"> '
 																					 +' </b><br>'
 																					 +' Ausgabe auf: <select id="loc" name="loc"> '
																					 +' <option value="de" selected>Deutsch</option> '
																					 +' 	<option value="nl">Nederlands</option> '
																					 +' 	<option value="tr">Türkçe</option> '
																					 +'    </select> '
																					 +'&nbsp;'
																					 +' <input name="submit" type="submit" value="berechnen..."> '
																					 +' </form> ';
	
}
// ---------------------------------------------------

function route_input()
{
	//alert('in func route_Input doing #1 -> map init');
	map_init();
	
//	alert('in func route_Input doing #2 -> displayform');
	displayForm1();
	
	//document.getElementById("div2").innerHTML = "Hier kommen die Eingabe-Felder hin";	

}