var SHOW_MAP = 'Lagekarte &ouml;ffnen';
var HIDE_MAP = 'Lagekarte schliessen';



var googleMap = {
    //----------------- properties -------------------
    //
	gMap: null,			// GMap2-Instanz
	gMarker: null,

    //----------------- methods ----------------------
	show: function(latitude, longitude, zoom, label) {
		if (!GBrowserIsCompatible()) {
			return;
		}

		var map = document.getElementById('googleMaps');
		if ((!map) || (map == null)) {
			return;
		}
		
		if ((!this.gMap) || (this.gMap == null)) {
			map.style.display = '';	

	   		this.gMap = new GMap2(map);
    	   	// this.gMap.addControl(new GSmallMapControl());
    	   	this.gMap.addControl(new GLargeMapControl());
   	   		// this.gMap.addControl(new GSmallZoomControl());
	       	this.gMap.addControl(new GScaleControl());
       		this.gMap.addControl(new GMapTypeControl());
		}


		zoom = ((zoom) && (zoom > 0)) ? zoom : 10;
		if (this.gMarker) {
			if (map.style.display != 'none') {
				map.style.display = 'none';
			} else {
				map.style.display = '';
				var point = new GLatLng(latitude, longitude)
				this.gMap.setCenter(point, zoom);
				this.gMap.checkResize();
			}
		} else {
			if ((latitude) && (longitude)) {
				map.style.display = '';						
				var point = new GLatLng(latitude, longitude);
				this.gMap.setCenter(point, zoom);
				this.gMarker = new GMarker(point, { title: label });
				this.gMap.addOverlay(this.gMarker);
				this.gMap.setCenter(point, zoom);
				this.gMap.checkResize();
			}	
		}
		
		map.parentNode.style.height = (map.style.display != 'none') ? "420px" : "20px";	

		var mapLink = document.getElementById('googleMapsLink');
		mapLink.innerHTML = (map.style.display != 'none') ? HIDE_MAP : SHOW_MAP;

		var mapHint = document.getElementById('googleMapsHint');
		mapHint.style.display = map.style.display;

	},
	
	hide: function() {
		var map = document.getElementById('googleMaps');
		map.style.display = 'none';

		var mapLink = document.getElementById('googleMapsLink');
		mapLink.innerHTML = SHOW_MAP;

		var mapHint = document.getElementById('googleMapsHint');
		mapHint.style.display = map.style.display;
	}
}



window.onload = function() {
	googleMap.hide();	
}

