
var map  = null;


function Westend_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 : 13;
	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());
	el._gmap.addControl(new GOverviewMapControl());
	el._gmap.addControl(new GMapTypeControl());
	el._gmap.enableScrollWheelZoom();
	
	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',
	coords             : new Array(51.33758793217993, 12.370871007442474),
	zoom               : 13,
	theInfo            : '<strong>Westend. Public Relations GmbH</strong><br />Martin-Luther-Ring 13<br />04109 Leipzig',
	theIcon            : 'resources/themes/standard/images/google_map.png',
	theIconSize        : new Array(20, 15),
	theIconAnchor      : new Array(20, 8),
	theInfoWindowAnchor: new Array(20, 8)
};


var onload_old = window.onload;

window.onload = function() {
	if(onload_old)
		onload_old();
	if(GBrowserIsCompatible()) {
		Westend_goggleMap(theMapData.gm_ukl);
	}
};

