var icon = new GIcon();
icon.image = "http://www.google.de/intl/de_de/mapfiles/arrow.png";
icon.shadow = "http://www.google.de/intl/de_de/mapfiles/arrowshadow.png";
icon.iconSize = new GSize(39, 34);
icon.shadowSize = new GSize(39, 34);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);


var geocoder = null;
var map = null;
var bounds = new GLatLngBounds();


function showAddress(address)
{
	var geocoder = new GClientGeocoder();
	for(i=0;i<address.length;i++)
	{
		geocoder.getLatLng(
			address[i],
			function(point)
			{
				if (!point)
				{
					alert(address[i] + " not found");
				}
				else
				{
					map.setCenter(point, 10);
					var marker = new GMarker(point, icon);
					map.addOverlay(marker);
					bounds.extend(marker.getPoint());
					var zoom = map.getBoundsZoomLevel(bounds);
					if (zoom <= 13)
					{
						map.setZoom(map.getBoundsZoomLevel(bounds));
					}
					else
					{
						map.setZoom(13);
					}
					map.setCenter(bounds.getCenter());

					GEvent.addListener(marker, "click", 
						function()
						{
							//location.href = "http://maps.google.de/maps?f=d&hl=de&z=12&geocode=&saddr=&daddr="+marker.getLatLng().toUrlValue();
							link = "http://maps.google.de/maps?f=d&hl=de&z=12&geocode=&saddr=&daddr="+marker.getLatLng().toUrlValue();
							window.open(link);
						}
					);
				}
			}
		);
	}
}


function showLocations(arrLocations)
{
	if (GBrowserIsCompatible())
	{
		//var geocoder = new GClientGeocoder();
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallZoomControl());
		map.setCenter(new GLatLng(0,0),0);
		showAddress(arrLocations);
	}
}

