//<![CDATA[

	var map 			= null;
	var geocoder 	= null;
	var bounds 		= null;

	function gmapLoad() {
	  if (GBrowserIsCompatible()) {
    	map = new GMap2(document.getElementById("map"));
      map.setCenter(new GLatLng(51.165567, 10.458984), 6);
      geocoder = new GClientGeocoder();
      bounds = new GLatLngBounds();
      showAddress('http://www.abarth-berlin.de/', 'Berlin');
      showAddress('http://www.abarth-hamburg.de/', 'Hamburg');
      showAddress('http://www.abarth-duesseldorf.de/', 'D&uuml;sseldorf');
      showAddress('http://www.abarth-essen.de/', 'Essen');
      showAddress('http://www.abarth-dortmund.de/', 'Dortmund');
	  }
	}

	function createListener (marker, text) {
		GEvent.addListener(marker, "click", function() { window.location.href = text; });
	}

	function createMarker (latlng, text) {
		var icon = new GIcon();
		icon.image = "/img/abarth-pin.png";
		icon.iconSize = new GSize(54.0, 45.0);
		icon.iconAnchor = new GPoint(0.0, 0.0);
		icon.infoWindowAnchor = new GPoint(0.0, 0.0);
		var markerLatlng = new GMarker(latlng, icon);
		map.addOverlay(markerLatlng);
		createListener (markerLatlng, text);
	}

	function showAddress(info, address) {
		if (geocoder) {
		  geocoder.getLatLng(
		    address,
		    function(point) {
		      if (point) {
						createMarker(point, info);
  					bounds.extend(point);
						var zoom = map.getBoundsZoomLevel(bounds);
						zoom = zoom - 1;
						if (zoom > 15) 	{zoom = 15;}
						map.setCenter(bounds.getCenter(), map.setZoom(zoom));
		      }
		    }
		  );
		}
	}

	function clearMap() {
		delete(bounds);
		map.clearOverlays();
	}
//]]>

