/**
 ** Information
 *
 * 	jQuery Google Map
 * 	Date: 			01/20/2010
 * 	Last Update 	01/28/2010
 * 	Version			0.2
 
 ** Configuration
 *
 *		coord: 			Information:	Geo Coordinates
 *				 			Default: 		00000,00000
 *							Type:				string
 *
 *		mapType:			Information:	Type of the google map
 *							Default:			normal
 *							Type:				string
 *							Allowed:			normal: 				displays the default road map view.
 * 											satellite: 			displays Google Earth satellite images.
 * 											hybrid:				displays a mixture of normal and satellite views.
 * 											defaultTypes:		contains an array of the above three types, useful for iterative processing.
 * 											physical:			displays a physical map based on terrain information. 
 *
 *		mapZoom			Information:	The level of zoom for the map
 *							Default:			16
 *							Type:				integer
 *
 *		tipImage:		Information:	Path for the tip image
 *							Default:			null
 *							Type:				string
 *
 *		tipWidth:		Information:	The width of the tip
 *							Default:			null
 *							Type:				integer
 *
 *		tipHeight:		Information:	The height of the tip
 *							Default:			null
 *							Type:				integer
 *
 *		shadowWidth:	Information:	The width of the tip's shadow
 *							Default:			80
 *							Type:				integer
 *
 *		shadowHeight:	Information:	The height of the tip's shadow
 *							Default:			52
 *							Type:				integer
 *
 *
**/


jQuery.fn.googleMap = function(options) {

	return this.each(function(){
		
		var $this = jQuery(this);
		
		var defaults = {
			  coordX				: null
			, mapType			: 'normal'
			, mapZoom			: 16
			, tipImage			: null
			, tipWidth			: 0
			, tipHeight			: 0
			, shadowWidth		: 80
			, shadowHeight		: 52
		};
		
		var opt = jQuery.extend(defaults, options);
		
		var mapTypes = {
			  normal				: G_NORMAL_MAP
			, satellite			: G_SATELLITE_MAP
			, hybrid				: G_HYBRID_MAP
			, defaultType		: G_DEFAULT_MAP_TYPES
			, physical			: G_PHYSICAL_MAP
		}
		
		if (GBrowserIsCompatible()) {
			var c 			= opt.coord.split(',');
			var x 			= c[0];
			var y 			= c[1];
			var coords 		= new GLatLng(x,y);
			var tip 			= new GIcon(G_DEFAULT_ICON);	
			tip.iconSize 	= new GSize(opt.tipWidth, opt.tipHeight);
			tip.shadowSize = new GSize(opt.shadowWidth, opt.shadowHeight);
			tip.image 		= opt.tipImage;
			markerOptions  = { icon:tip };
			
			var map = new GMap(this);  
			map.setCenter(coords, opt.mapZoom);
			map.setUIToDefault();
			map.setMapType(mapTypes[opt.mapType]);
			map.addOverlay(new GMarker(coords, markerOptions));
		}
	});
};
