﻿﻿;(function($){$.fn.gMap=function(options){var defaults={height:400,markersListId:"markers",showFirstMarkerBalloonOnLoad:false,width:400,zoom:15};var options=$.extend({},defaults,options);var map;var markers=new Array();var infoWindows=new Array();var closeInfoWindows=function(){$.each(infoWindows,function(i){if(infoWindows[i])
infoWindows[i].close();});}
var openInfoWindow=function(i,map){closeInfoWindows();infoWindows[i].open(map,markers[i]);}
return this.each(function(index){var $mapFrame=$(this).css({"height":options.height,"width":options.width});var mapCenterLatLngString=$mapFrame.attr("title");var mapCenterLatLngArray=mapCenterLatLngString.split(",");var mapCenterLatLng=new google.maps.LatLng(mapCenterLatLngArray[0],mapCenterLatLngArray[1]);var mapOptions={zoom:options.zoom,center:mapCenterLatLng,mapTypeId:google.maps.MapTypeId.ROADMAP};map=new google.maps.Map($mapFrame[0],mapOptions);var $listMarkers=$("#"+options.markersListId+" abbr").each(function(i){$this=$(this);$description=$this.next("p").hide();thisMarkerDescription=$description.html();thisMarkerLetter=String.fromCharCode("A".charCodeAt(0)+i);thisMarkerLatLng=$this.attr("title");thisMarkerTitle="<h3>"+$this.html()+"<\/h3>";thisMarkerContent=thisMarkerTitle;if(thisMarkerDescription)
thisMarkerContent+=thisMarkerDescription;infoWindows[i]=new google.maps.InfoWindow({content:thisMarkerContent});thisMarkerLatLngArray=thisMarkerLatLng.split(",");thisMarkerLatLng=new google.maps.LatLng(thisMarkerLatLngArray[0],thisMarkerLatLngArray[1]);markers[i]=new google.maps.Marker({icon:"http://www.google.com/mapfiles/marker"+thisMarkerLetter+".png",map:map,position:thisMarkerLatLng,title:thisMarkerTitle});google.maps.event.addListener(markers[i],'click',function(){openInfoWindow(i,map);});$this.click(function(){openInfoWindow(i,map);}).css({"cursor":"pointer"});});if(options.showFirstMarkerBalloonOnLoad)
openInfoWindow(0,map);});};})(jQuery);
