var map;var gdir;var geocoder=null;var addressMarker;var address='';function loadGoogleMap(){geocoder=new GClientGeocoder();if(GBrowserIsCompatible()){map=new GMap2(document.getElementById("GMap"),{size:new GSize(450,500)});map.setUIToDefault();var myDiv=document.getElementById("GDirections");gdir=new GDirections(map,myDiv);GEvent.addListener(gdir,"error",handleErrors);if(geocoder){geocoder.getLatLng(address,function(point){if(!point){alert(address+" not found")}else{map.setCenter(point,14);var marker=new GMarker(point);map.addOverlay(marker);marker.openInfoWindowHtml(address?(address):(title))}})}}}function setDirections(fromAddress){if(address&&gdir){$("#GDirections").html("");if(address.length>1){gdir.load("from: "+fromAddress+" to: "+address,{"locale":"de"})}}}function handleErrors(){if(gdir.getStatus().code==G_GEO_UNKNOWN_ADDRESS){$("#GDirections").html("Es konnte keine entsprechende geografische Position für die angegebene Adresse gefunden werden. Dies kann daran liegen, dass die Adresse relativ neu oder möglicherweise falsch ist.")}else if(gdir.getStatus().code==G_GEO_SERVER_ERROR){$("#GDirections").html("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){$("#GDirections").html("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){$("#GDirections").html("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){$("#GDirections").html("A directions request could not be successfully parsed.\n Error code: "+gdir.getStatus().code)}else{$("#GDirections").html("An unknown error occurred.")}}$(function(){$("#GMapInputSubmit").click(function(){setDirections($("#GMapInputText").val());return false})})
