/**
 * Library function to convert a block level element into a Google Maps
 * tool. 
 *
 * @param options {Object} which comprises the following:
 *  address  : an array of strings for the address
 *  longitude: longitudinal focus of the map
 *  latitude : latitudinal focus of the map
 *  zoom     : zoom level
 *  geocode  : the geocode query for google to resolve
 *  
 * @todo find out why surrounding the address passed into openInfoWindowHtml()
 * with <p> creates an artificially large popup widnow.
 */
jQuery.fn.createMap = function(options) {
   
   
   if (GBrowserIsCompatible()) {
      $(window).unload( function () { GUnload()} );

      var geocoder = new GClientGeocoder();
      
      var centre = new GLatLng(options.longitude,options.latitude);
      var map = new GMap2(this.get(0));

      map.setCenter(centre, options.zoom);
      map.setMapType(G_HYBRID_MAP);

      geocoder.getLatLng(options.geocode, function(point) {
         if (point) {
            map.openInfoWindowHtml(point, '<span>'+options.address.join('<br />')+'</span>', {
                                       noCloseOnClick:true
                                    });
         } else {

         }
      });
      
      map.addControl(new GLargeMapControl());      

   }
}