try{
	var geocoder = new GClientGeocoder();
} catch (e) {}

var map1 = null;
var map2 = null;

// =================================================
// GinitMap
function GinitMap(mapId, location, mapType, pushPin, zoom) {
	//alert(location);
	
	if (GBrowserIsCompatible()) {
	 	// init der 1. Map, die immer sichtbar ist
		map1 = GinitSingleMap(mapId, location, mapType, pushPin, zoom, false, false);

		var mapId2 = mapId.replace("MAPPanel", "MAPPanelFull");
		// init der 2. Zoom-Map
		//map2 = GinitSingleMap(mapId2, location, mapType, pushPin, zoom, false, true); 
		
		// register UnLoad Handler for Garbage Collection
		dojo.addOnUnload(window, 
			function() { 
				GUnload();
				// alert("unloaded");		
			}
		);
	} // END: if (GBrowserIsCompatible())
}

// =================================================
// GinitBigMap
function GinitBigMap(mapId, location, mapType, pushPin, zoom) {
	//alert(location);
	
	if (GBrowserIsCompatible()) {
		var mapId2 = mapId.replace("MAPPanel", "MAPPanelFull");
		// init der 2. Zoom-Map
		map2 = GinitSingleMap(mapId2, location, mapType, pushPin, zoom, false, true); 
		
		// register UnLoad Handler for Garbage Collection
		dojo.addOnUnload(window, 
			function() { 
				GUnload();
				// alert("unloaded");		
			}
		);
	} // END: if (GBrowserIsCompatible())
}

// =================================================
// GinitSingleMap
function GinitSingleMap(id, location, mapType, pushPin, zoom, toolbar, showInfo) {
	var map = new GMap2(document.getElementById(id));

	map.enableContinuousZoom();
	map.enableScrollWheelZoom();
	map.addControl(new GSmallMapControl());
    // map.addControl(new GMapTypeControl());

	if(toolbar) {
		map.enableGoogleBar();
	}
	//map.setZoom(zoom);
	showAddress(location, map, zoom, id);
		
	// Map Stile initialisieren
	var mapTypeStyle = G_HYBRID_MAP;
	switch (mapType) {
	  case "Hybrid":
	    mapTypeStyle = G_HYBRID_MAP;
	    break;
	  case "Road":
	    mapTypeStyle = G_NORMAL_MAP;
	    break;
	  case "Aerial":
	    mapTypeStyle = G_SATELLITE_MAP;
	    break;
	  default:
	    mapTypeStyle = G_HYBRID_MAP;
	    break;
	}	
	map.setMapType(mapTypeStyle);
	
	return map;
}

// =================================================
// showAddress
function showAddress(address, map, zoom, showInfo, id) {

	if (geocoder!=null) {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					// address not found => hide the map
				} else {
					//map.checkResize();					
					map.setCenter(point, parseInt(zoom));
					var marker = new GMarker(point);
					map.addOverlay(marker);
					if(showInfo==true) {
						marker.openInfoWindowHtml(address);
					}
					map.checkResize();					
					map.setCenter(point, parseInt(zoom));
				}
			}
		);
	}
}


