var map;
var icon = new GIcon();
var geocoder = new GClientGeocoder();

function initMap(id, point) {

	icon.image = "http://labs.google.com/ridefinder/images/mm_20_yellow.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);
	    
	map = new GMap2(document.getElementById(id), G_SATELLITE_MAP);
	map.setCenter(point, 11);
	
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	
	var bounds = map.getBounds();
	var width = bounds.maxX - bounds.minX;
	var height = bounds.maxY - bounds.minY;

	return map;
	
}

// Create a marker whose info window displays the given number.
function createCenterMarker(point, number) {
  var marker = new GMarker(point);

  // Show this marker's info window when it is clicked.
  var html = number;
  GEvent.addListener(marker, 'click', function() {
	marker.openInfoWindowHtml(html);
  });
  
  map.addOverlay(marker);
  
  return marker;
}

function createInfoMarker(point, number) {
  var marker = new GMarker(point, icon);

  // Show this marker's info window when it is clicked.
  var html = number;
  GEvent.addListener(marker, 'click', function() {
	marker.openInfoWindowHtml(html);
  });

  return marker;
}

function createMarkerFromPoint(point, markup) {
	var marker = new GMarker(point, icon);
    map.addOverlay(marker);
    GEvent.addListener(marker, 'click', function() {
	marker.openInfoWindowHtml(markup);
	});
}

function createMarker(address, markup) {
	
	 geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        //alert(address + " not found");
        // could not geocode address... ignore
      } else {
        var marker = new GMarker(point, icon);
        map.addOverlay(marker);
        GEvent.addListener(marker, 'click', function() {
        map.setCenter(point);
		marker.openInfoWindowHtml(markup);
	  });
      }
    }
  );
	
	
	
}

