// 
//  jquery.googlemap.js
//  Cutpastecreate
//  
//  Created by Chris Mytton on 2009-05-17.
//  Copyright 2009 Cutpastecreate. All rights reserved.
// 
(function ($) {
	$.fn.googleMap = function (options) {
		return this.each(function () {
			try
			{
				// extend a blank object with our defaults, then with the supplied options.
				var opts = $.extend({}, $.fn.googleMap.defaults, options);

				// check that the users browser is compatible with google maps
				if (GBrowserIsCompatible() === true)
				{
					// create a new map object using the jQuery object
					var map = new GMap2(this),
					point = new GLatLng(opts.lat, opts.lng),
					marker = new GMarker(point);

					// set the user interface to the default
					map.setUIToDefault();

					// add point to the map
					map.addOverlay(marker);

					// set the maps centre and zoom level
					map.setCenter(point, opts.zoom);
				}
			}
			catch (e)
			{
				opts.debug && window.console && console.log(e);
			}
		});
	};
	
	// default options
	$.fn.googleMap.defaults = {
		lat: 51.694874,
		lng: -2.217489,
		zoom: 9,
		debug: false
	};
})(jQuery);