/**
 * Displays a google map.
 *
 * @param lat Latitude  of the point to display.
 * @param lng Longitude of the point to display.
 * @param zoom Zoom factor (0-19), default is 13.
 * @param showMarker If true a marker will be displayed at the point, nothing when false. Default is no marker.
 * @param markerText Text of the marker, null means no text.
 * @param compIssueMessage Message to display when browser compatibiliy problems occur.
 */

$.fn.googleMap = function(lat, lng, zoom, showMarker, markerText, compIssueMessage) {
  return this.each(function() {
    if (GBrowserIsCompatible()) {
      var cord = new GLatLng(lat, lng);
      var map = new GMap2(this);
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(cord, zoom == null ? 13 : zoom);
      if (showMarker) {
        var marker = new GMarker(cord);
        map.addOverlay(marker);
        if (markerText != null) {
          marker.openInfoWindowHtml(markerText);
        }
      }
    } else {
      alert(compIssueMessage == null ? "Your Browser is not compatible with Google Maps!" : compIssueMessage);
      return false;
    }
  });
};
