//GMaps Javascript
var map = null;
var geocoder = null;

function initialize() {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map_canvas"));
	
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	
	map.setCenter(new GLatLng(13.3, 51.3), 13);
	map.setMapType(G_SATELLITE_MAP);
	geocoder = new GClientGeocoder();
  }
}

function showAddress(address, text, zoom)
{	if (zoom < 1) {
		zoom = 13;
	}
	
	if (geocoder) {
		geocoder.getLatLng(
		address,
		function(point) 
		{	if (!point) {
				alert(address + " konnte nicht gefunden werden!");
			} else {
				map.setCenter(point, zoom);
				map.setMapType(G_SATELLITE_MAP);
				var marker = new GMarker(point);
				
				GEvent.addListener(marker, "mouseover", function()
				{
					marker.openInfoWindowHtml(text);
				});
				GEvent.addListener(marker, "mouseout", function()
				{
					map.disableInfoWindow();
					map.enableInfoWindow();
				});

				map.addOverlay(marker);
				marker.openInfoWindowHtml(address);
			}
		}
		);
	}
}
