/**
 * Stef A. Spijkerman
 * http://www.saspijkerman.com/
 * mail@saspijkerman.com
 *
 * Version : 1.0
 * Date    : June 26th, 2009
 *
 * Options :
 *
 * class_name : Add this [string] to the elements class-attribute
 *              (default : 'external')
 * title      : New title [string] as the title-attribute
 *              (default : 'Google Maps')
 * url        : Use this [string] as the googlemaps url
 *              (default : 'http://maps.google.com/')
 *
 * example 1 :
 * $('address').googlemaps();
 *
 * example 2 :
 * $('address').googlemaps({
 *    class_name : 'link',
 *    url : 'http://maps.google.nl/',
 *    title : 'link to Google Maps'
 * });
 *
 */

(function(){

	jQuery.fn.googlemaps = function(settings) {

		settings = jQuery.extend({
			class_name : 'googlemaps',
			title      : 'Google Maps',
			url        : 'http://maps.google.com/'
		}, settings);

		jQuery(this).attr(
			'title', settings.title
		).addClass(
			settings.class_name
		).click(function() {
			var url = settings.url
				+ '?t=h&q='
				+ escape($(this).html());
			return !window.open(url);
		});

	};

})(jQuery);
