/**
 * google-maps-koordinaten.js - (c) <http://www.teledir.de>
 */
(function(){google.load("maps","2");$(function(){var A=new google.maps.Map2(document.getElementById("map")),C=new GClientGeocoder(),D=null,I=12;A.addControl(new GSmallMapControl());A.addControl(new GMapTypeControl());GEvent.addListener(A,"click",function(J,K){if(K){D.setLatLng(K);if(C){C.getLocations(K,function(L){if(!L||L.Status.code!=200){B(K,{city:"",address:""});}else{B(K,{address:H(L,"address"),city:H(L,"city")});}});}else{B(D.getLatLng(),{city:"",address:""});}}});if(google.loader.ClientLocation){var G=new google.maps.LatLng(google.loader.ClientLocation.latitude,google.loader.ClientLocation.longitude);C.getLocations(G,function(J){if(J&&J.Status.code==200){B(G,{address:H(J,"address"),city:H(J,"city")});}else{B(G,{city:google.loader.ClientLocation.address.city,address:google.loader.ClientLocation.address.city});}});}else{B(new google.maps.LatLng(51.165691,10.451526),{city:"",address:""});}$("#input-location").keypress(function(J){if(J.which==13){F();}});$("#button-find-coordinates").click(function(){F();});function F(){C.getLatLng($("#input-location").val(),function(J){if(J){C.getLocations(J,function(K){if(K&&K.Status.code==200){B(J,{address:H(K,"address"),city:H(K,"city")||""});}else{B(J,{city:"",address:""});}});}else{}});}function B(J,K){$("#input-location-lat").val(J.y);$("#input-location-lon").val(J.x);$("#input-location-lat-string").html(E(J.x)+" Nord");$("#input-location-lon-string").html(E(J.y)+" Ost");if(K.city&&K.city.length>0){$("#input-location").val(K.city);}if(K.address&&K.address.length>0){$("#label-location").html(K.address);}A.setCenter(J,I);if(!D){D=new GMarker(J,{draggable:true});GEvent.addListener(D,"dragend",function(){if(C){C.getLocations(D.getLatLng(),function(L){if(!L||L.Status.code!=200){B(D.getLatLng(),{city:"",address:""});}else{B(D.getLatLng(),{address:H(L,"address"),city:H(L,"city")});}});}else{B(D.getLatLng(),{city:"",address:""});}});A.addOverlay(D);}else{D.setLatLng(J);C.getLocations(J,function(L){$("#input-location").val(H(L,"city"));$("#label-location").html(H(L,"address"));});}}function H(M,L){var J="";switch(L){case"city":try{J=M.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;}catch(K){}break;case"address":try{J=M.Placemark[0].address;}catch(K){}break;}return J;}function E(L){var M=L-parseInt(L);var J=M*60;M=J-parseInt(J);var K=M*60;return parseInt(L)+"&deg; "+parseInt(J)+"' "+K.toFixed(2)+'"';}});})();
