(function( $ ){
	$.fn.zoomMap = function( options ) {
	
		var settings = {
			'width'		: 300,
			'height'	: 200,
			'speed'		: 1000,
			'zoom'		: 16,
			'location'	: '49.899192, -97.141759',
			'link'		: false
		};
	
		return this.each(function() {
		
			// If options exist, merge them with default settings
			if ( options ) {
				$.extend( settings, options );
			}
	
			// Plugin code here
			var $this = $(this);
			
			var width = settings['width'];
			var height = settings['height'];
			var shiftLeft = Math.floor(width/2)*(-1);
			var shiftTop = Math.floor(height/2)*(-1);
			var src = 'http://maps.googleapis.com/maps/api/staticmap?center='+encodeURI(settings['location'])+'&zoom='+settings['zoom']+'&size='+(width*2)+'x'+(height*2)+'&maptype=roadmap&sensor=false&scale=2&markers=color:green%7Clabel:DT%7C'+encodeURI(settings['location']);
			var $img = $('<img src="'+src+'" alt="map" />');
			
			$this.html($img);
			
			// wrap image with link to Google Map
			if (settings['link']){
				var url = 'http://maps.google.com/?q='+encodeURI(settings['location'])+'&z='+settings['zoom'];
				$img.wrap('<a href="'+url+'"></a>');
			}
			
			$img.css({
				'display'	:	'block',
				'position'	:	'relative',
				'overflow'	:	'hidden',
				'margin'	:	0,
				'padding'	:	0,
				'left'		:	0,
				'top'		:	0,
				'width'		:	'100%',
				'height'	:	'100%'
			});
			
			// Map Zoom
			$this.css({
				'display'	:	'block',
				'position'	:	'relative',
				'overflow'	:	'hidden',
				'width'		:	width,
				'height'	:	height
			}).hover(
				function() {
					$img.stop().animate({
						width	: width*2,
						height	: height*2,
						left	: shiftLeft,
						top		: shiftTop,
					}, settings['speed'], function() {
						// Animation complete.
					});
				},
				function() {
					$img.stop().animate({
						width	: width,
						height	: height,
						left	: 0,
						top		: 0
					}, settings['speed'], function() {
						// Animation complete.
					});
				}
			);
		});
	};
})( jQuery );
