/* jQuery GPS plugin -- Copyright 2009 Bird Wing Productions, http://www.birdwingfx.com * updated to include directionsLoaded callback by Warehouse Multimedia */
(function($){$.GoogleMapObjectDefaults={zoomLevel:10,imagewidth:50,imageheight:50,center:'2000 Florida Ave NW Washington, DC 20009-1231',start:'#start',end:'#end',directions:'directions',submit:'#getdirections',tooltip:'false',image:'false',directionsLoaded:null};function GoogleMapObject(elementId,options){this._inited=false;this._map=null;this._geocoder=null;this.ElementId=elementId;this.Settings=$.extend({},$.GoogleMapObjectDefaults,options||'');} $.extend(GoogleMapObject.prototype,{init:function(){if(!this._inited){if(GBrowserIsCompatible()){this._map=new GMap2(document.getElementById(this.ElementId));this._map.addControl(new GSmallMapControl());this._geocoder=new GClientGeocoder();} this._inited=true;}},load:function(){this.init();if(this._geocoder){var zoom=this.Settings.zoomLevel;var center=this.Settings.center;var width=this.Settings.imagewidth;var height=this.Settings.imageheight;var map=this._map;if(this.Settings.tooltip!='false'){var customtooltip=true;var tooltipinfo=this.Settings.tooltip;} if(this.Settings.image!='false'){var customimage=true;var imageurl=this.Settings.image;} this._geocoder.getLatLng(center,function(point){if(!point){alert(center+" not found");} else{map.setCenter(point,zoom);if(customimage==true){var customiconsize=new GSize(width,height);var customicon=new GIcon(G_DEFAULT_ICON,imageurl);customicon.iconSize=customiconsize;var marker=new GMarker(point,{icon:customicon});map.addOverlay(marker);}else{var marker=new GMarker(point);map.addOverlay(marker);} if(customtooltip==true){marker.openInfoWindowHtml(tooltipinfo);}}});} $.data($(this.Settings.submit)[0],'inst',this);$(this.Settings.submit).click(function(e){e.preventDefault();var obj=$.data(this,'inst');var outputto=obj.Settings.directions;var from=$(obj.Settings.start).val();var to=$(obj.Settings.end).val();if(from&&to) {map.clearOverlays();var gdir=new GDirections(map,document.getElementById(outputto));gdir.load("from: "+from+" to: "+to);GEvent.addListener(gdir,"load",function(){$(obj.Settings.directionsLoaded);});}});return this;}});$.extend($.fn,{googleMap:function(options){var mapInst=$.data(this[0],'googleMap');if(mapInst){return mapInst;} mapInst=new GoogleMapObject($(this).attr('id'),options);$.data(this[0],'googleMap',mapInst);return mapInst;}});})(jQuery);

$(document).ready(function(){
	
	$('#map').googleMap({
		center: 			'410 West McKnight Dr. Murfreesboro, TN 37129',
		zoomLevel: 			15,
		tooltip: 			'<img src="contact-us/directions/3bc.gif" style="float:left;margin-right:10px;" /><strong>Third Baptist Church</strong><br />410 West McKnight Dr.<br />Murfreesboro, TN 37129',
		directionsLoaded: 	function(){$('#print').show();$('#loading').hide();}
	}).load();
	
	$('#getdirections').click(function(){
		if($('#start').val()){
			$('#print').hide();
			$('#loading').show();
		}
	});
});

