/** created by Denny Koch */

$.fn.showStaticGoogleMap = function(width, height, zoom, maptype) {
	
	if(!maptype) maptype = 'roadmap';
	
	if(!zoom) zoom = 14;
		
	if(!width) width = 512;
	if(!height) height = width;
	
	$(this).each(function() {
		
		var location = $(this).attr('src');
		
		var repl = / /gi;
		
		location = location.replace(repl, '+');
		
		var map = 'http://maps.google.com/maps/api/staticmap?zoom='+zoom+'&size='+width+'x'+height
				 +'&maptype=roadmap&sensor=false'
				 +'&markers=color:blue|'+location+'&sensor=true_or_false';
		
		$(this).attr('src', map);
		
		var link = $('<a></a>').insertAfter($(this));

		link.attr('target', '_blank');
		link.attr('href', 'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q='+location);
		link.addClass('googlemaplink');
		
		link.html($(this));
		
	});
	
}

$(document).ready(function() {
	$('.googlemap').showStaticGoogleMap(300);
});
