function resizeMap(map, points)
{
	var minLong = 999;
	var minLat = 999;
	var maxLong = -999;
	var maxLat = -999;

	// Get the current map width/height
	var size = map.getSpanLatLng();
	var mapWidth = size.width;
	var mapHeight = size.height;
	var baseWidth = mapWidth;
	var baseHeight = mapHeight;

	// Figure out the elemental unit (depends on the size of the map)
	// You will need to re-run resizeMap() if the size of the map changes.
	if (map.getZoomLevel() > 0)
	{
		baseWidth /= Math.pow(2, map.getZoomLevel());
		baseHeight /= Math.pow(2, map.getZoomLevel());
	}

	// Find the max/min points
	for (var i = 0; i < points.length; i++)
	{
		if (points[i].x < minLong) minLong = points[i].x;
		if (points[i].x > maxLong) maxLong = points[i].x;
		if (points[i].y < minLat) minLat = points[i].y;
		if (points[i].y > maxLat) maxLat = points[i].y;
	}

	// Find the optimal Width Zoom
	var wZoom = 0;
	var w = Math.abs(maxLong - minLong);
	for (var i = 1; i < 16; i++)
	{
		if (baseWidth > w) break;
		baseWidth *= 2;
		wZoom = i;
	}

	// Find the optimal Height Zoom
	var hZoom = 0;
	var h = Math.abs(maxLat - minLat);
	for (var i = 1; i < 16; i++)
	{
		if (baseHeight > h) break;
		baseHeight *= 2;
		hZoom = i;
	}
	
	// Reposition
	map.centerAndZoom(new GPoint(( minLong + maxLong) / 2, (minLat + maxLat) / 2), (wZoom > hZoom ? wZoom : hZoom));
}

function showTooltip(marker, tooltip, map)
{
	tooltip.innerHTML = marker.tooltip;
	var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
	var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
	var anchor=marker.getIcon().iconAnchor;
	var width=marker.getIcon().iconSize.width;
	var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width,- offset.y + point.y +anchor.y)); 
	pos.apply(tooltip);
	tooltip.style.visibility="visible";
}

function createMarker(point, desc, tooltip, map, target)
{
	var icon = new GIcon();
	icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
	icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	icon.iconSize = new GSize(12, 20);
	icon.shadowSize = new GSize(22, 20);
	icon.iconAnchor = new GPoint(6, 20);
	icon.infoWindowAnchor = new GPoint(5, 1);
	var marker = new GMarker(point, icon);
	marker.tooltip = '<div class="tooltip">' + desc + '</div>';
	GEvent.addListener(marker, "click", function() { top.location.replace("http://www.czech360.com/" + target); });
	GEvent.addListener(marker,"mouseover", function() { showTooltip(marker, tooltip, map); });        
	GEvent.addListener(marker,"mouseout", function() { tooltip.style.visibility="hidden" });        
	return marker;
}
