/**
 * 1. Include jQuery on the page
 * 2. Call $('#container_selector').googleMap('#selector_to_get_address_from');
 * 
 * The address will be pulled from the specified selector. All newlines and
 * break tags will be removed.
 * 
 * @version 1.0.1
 * @changes 1.0.1  Fixed a bug with br tags in IE [wb, 2010-05-10]
 * @changes 1.0.0  Initial implementation [wb, 2009-??-??]
 */
(function($) {

	$.googleMap = function(container, address_source) {  
		var address = $(address_source).html().replace('\n', ' ').replace(/<br ?\/?>/i, ' ').replace(/^\s+|\s+$/g, '');
		var iframe  = $('<iframe frameborder="0" scrolling="no" marginheight="0"></iframe>');
		var url     = 'http://maps.google.com/maps?f=q&hl=en&source=s_q&ie=UTF8&z=14&iwloc=A&q=' + escape(address) + '&output=embed';
		iframe.attr('src', url);
		iframe.appendTo(container);
	}
	
	$.fn.googleMap = function(address_source) {
		this.each(function() {
			new $.googleMap(this, address_source);
		});
		return this;
	};
	
})(jQuery);
