/**
* Clobes & Kollegen RAe
* JavaScript Google Maps
*/

var map  = null;


function UKL_goggleMap(el) {
	if(!el)
		return;

	var mHolder           = (document.getElementById(el.holder)) ? document.getElementById(el.holder) : null;
	var mCoordX           = (el.coords[0]) ? el.coords[0] : null;
	var mCoordY           = (el.coords[1]) ? el.coords[1] : null;
	var mZoom             = (el.zoom>0) ? el.zoom : 14;
	var mText             = (el.theInfo) ? el.theInfo : null;
	var mIcon             = (el.theIcon) ? el.theIcon : null;
	var mIconSize         = el.theIconSize;
	var mIconAnchor       = el.theIconAnchor;
	var mInfoWindowAnchor = el.theInfoWindowAnchor;

	if(mHolder==null || mCoordX==null || mCoordY==null)
		return;

	el._gmap    = null;
	el._gicon   = null;
	el._gmarker = null;

	/*alert('Coords...: '+mCoordX+'-'+mCoordY+'\n'+
	      'Zoom.....: '+mZoomFactor+'\n'+
	      'Icon.....: '+mIcon+'\n'+
	      'Text.....: '+mText+'\n');*/

	el._gmap = new GMap2(mHolder);
	el._gmap.addControl(new GSmallMapControl());

	//Karte|Satellit|Hybrid
	//el._gm.addControl(new GMapTypeControl());
	el._gmap.setCenter(new GLatLng(mCoordX, mCoordY), mZoom);

	//Symbol
	if(mIcon!=null) {
		el._gicon                  = new GIcon();
		el._gicon.image            = mIcon;
		el._gicon.iconSize         = new GSize(mIconSize[0], mIconSize[1]);
		el._gicon.iconAnchor       = new GPoint(mIconAnchor[0], mIconAnchor[1]);
		el._gicon.infoWindowAnchor = new GPoint(mInfoWindowAnchor[0], mInfoWindowAnchor[1]);

		el._gmarker = new GMarker(new GLatLng(mCoordX, mCoordY), el._gicon);
		el._gmap.addOverlay(el._gmarker);
	}

	if(mText!=null) {
		GEvent.addListener(el._gmarker, 'click', function() {
			el._gmarker.openInfoWindowHtml(mText);
		});

		el._gmarker.openInfoWindowHtml(mText);
	}
}

var theMapData = {};
theMapData.gm_ukl = {
	holder             : 'google_map_one',
	coords             : new Array(51.523333, 12.32955),
	zoom               : 14,
	theInfo            : '<h1>Stadtverwaltung Delitzsch</h1>Schlo&szlig;stra&szlig;e 30<br />04509 Delitzsch',
	theIcon            : 'image/google_map.png',
	theIconSize        : new Array(37, 32),
	theIconAnchor      : new Array(18, 16),
	theInfoWindowAnchor: new Array(30, 5)
};


var onload_old = window.onload;

window.onload = function() {
	if(onload_old)
		onload_old();
	if(GBrowserIsCompatible()) {
		UKL_goggleMap(theMapData.gm_ukl);
	}
};

