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 )
  );
}


// Create a marker whose info window displays the given number.
function createMarker(point, comment) {
  var marker = new GMarker(point);
  // Show this marker's comment in the info window when it is clicked.
  GEvent.addListener(marker, 'click', function() {
	marker.openInfoWindowHtml(comment);
  });

  return marker;
}


// Create a marker whose info window displays the given number.
function createIconMarker(point, index, comment) {
  var letter = String.fromCharCode("A".charCodeAt(0) + index);
  var icon = new GIcon(baseIcon);
  icon.image = "images/letonthenet/map/marker" + letter + ".png";
  var marker = new GMarker(point, icon);
    // Show this marker's comment in the info window when it is clicked.
    GEvent.addListener(marker, 'click', function() {
      marker.openInfoWindowHtml(comment);
    });
  return marker;
}
