﻿var map = null;
var geocoder = null;
var bounds = null;
function initMap(mapId, coord1, coord2, zoom)
{
				if (GBrowserIsCompatible())
				{
								map = new GMap2(document.getElementById(mapId));
								map.setCenter(new GLatLng(parseFloat(coord1), parseFloat(coord2)));
								map.setUIToDefault();
								map.setZoom(zoom);
				}
};

function showAddress(address, businessName, businessUrl)
{
				if (!geocoder)
				{
								geocoder = new GClientGeocoder();
				}
				if (geocoder)
				{
								geocoder.getLatLng(address,
												function(point)
												{
																if (point)
																{
																				map.addOverlay(createMarker(point, businessName, address, businessUrl));
																}
												}
								);
				}
}
function createMarker(point, businessName, address, businessUrl)
{
  var marker = new GMarker(point);
  if(!bounds)
  {
				bounds = new GLatLngBounds();
  }
  bounds.extend(point);

  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml('<a target="_blank" href="' + businessUrl + '">' + businessName + '</a><br />' + address);
  });
  return marker;
}
