
(function($){$.fn.GoogleMap=function(addresses,titles,details,options){var defaults={type:0,width:'600px',height:'400px',zoom:10,clickable:true,tooltip:true,tipsuffix:' (click for more)'};var options=$.extend(defaults,options);var maptype=getGoogleMapID(options.type);var apiDefaults={mapTypeId:maptype,zoom:options.zoom}
return this.each(function(i,e){var $e=$(e);var apiCenter=new google.maps.LatLng(0,0);var apiMap=new google.maps.Map($e.get(0),$.extend(apiDefaults,{center:apiCenter}));if(!$e.hasClass('mapGoogle')){$e.addClass('mapGoogle');$e.css('width',options.width);$e.css('height',options.height);}
if(addresses){if(addresses.length>0){var i=0;while(i<addresses.length){getGeoCode(apiCenter,apiMap,i++);}}}});function getGeoCode(apiCenter,apiMap,index){var apiGeocoder=new google.maps.Geocoder();if(addresses&&index>=0){apiGeocoder.geocode({address:addresses[index]},function(results,status){if(status==google.maps.GeocoderStatus.OK&&results.length){if(status!=google.maps.GeocoderStatus.ZERO_RESULTS){apiMap.setCenter(results[0].geometry.location);var title='';if(options.tooltip)title=titles[index]+options.tipsuffix;var apiMarker=new google.maps.Marker({position:results[0].geometry.location,map:apiMap,title:title});var apiInfoWindow=new google.maps.InfoWindow({content:details[index]});if(options.clickable)
google.maps.event.addListener(apiMarker,'click',function(){apiInfoWindow.open(apiMap,apiMarker);});}}});}}
function getGoogleMapID(map){var mapid=google.maps.MapTypeId.ROADMAP;switch(map){case 1:mapid=google.maps.MapTypeId.SATELLITE;break;case 2:mapid=google.maps.MapTypeId.HYBRID;break;case 3:mapid=google.maps.MapTypeId.TERRAIN;break;}
return mapid;}};})(jQuery);
