

(function(a){jQuery.fn.extend({click:function(a){return this.addEventListener("click",a)},rightclick:function(a){return this.addEventListener("rightclick",a)},dblclick:function(a){return this.addEventListener("dblclick",a)},mouseover:function(a){return this.addEventListener("mouseover",a)},mouseout:function(a){return this.addEventListener("mouseout",a)},drag:function(a){return this.addEventListener("drag",a)},dragend:function(a){return this.addEventListener("dragend",a)},triggerEvent:function(a){google.maps.event.trigger(this.get(0),a)},addEventListener:function(a,b){if(this.get(0)instanceof google.maps.MVCObject){google.maps.event.addListener(this.get(0),a,b)}else{this.bind(a,b)}return this}});a.widget("ui.gmap",{options:{backgroundColor:null,center:new google.maps.LatLng(0,0),disableDefaultUI:false,disableDoubleClickZoom:false,draggable:true,draggableCursor:null,draggingCursor:null,keyboardShortcuts:true,mapTypeControl:true,mapTypeControlOptions:null,mapTypeId:google.maps.MapTypeId.ROADMAP,navigationControl:true,navigationControlOptions:null,noClear:false,scaleControl:false,scaleControlOptions:null,scrollwheel:false,streetViewControl:true,streetViewControlOptions:null,zoom:5,callback:null},_create:function(){a.ui.gmap.instances[this.element.attr("id")]={map:new google.maps.Map(this.element[0],this.options),markers:[],bounds:null,services:[]}},_init:function(){a.ui.gmap._trigger(this.options.callback,this.getMap());return a(this.getMap())},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments);this.getMap().setOptions(this.options)},addBounds:function(b){var c=a.ui.gmap.instances[this.element.attr("id")];if(!c.bounds){c.bounds=new google.maps.LatLngBounds}c.bounds.extend(b);c.map.fitBounds(c.bounds)},addControl:function(b,c){this.getMap().controls[c].push(a.ui.gmap._unwrap(b))},addMarker:function(b,c){var d=new google.maps.Marker(jQuery.extend({map:this.getMap(),bounds:false},b));this.getMarkers().push(d);if(d.bounds){this.addBounds(d.getPosition())}a.ui.gmap._trigger(c,this.getMap(),d);return a(d)},addInfoWindow:function(b,c){var d=new google.maps.InfoWindow(b);a.ui.gmap._trigger(c,d);return a(d)},displayDirections:function(b,c,d){var e=a.ui.gmap.instances[this.element.attr("id")];if(!e.services.DirectionsService){e.services.DirectionsService=new google.maps.DirectionsService}if(!e.services.DirectionsRenderer){e.services.DirectionsRenderer=new google.maps.DirectionsRenderer(jQuery.extend({map:e.map},c))}e.services.DirectionsService.route(b,function(b,f){if(f===google.maps.DirectionsStatus.OK){if(c.panel){e.services.DirectionsRenderer.setDirections(b)}}else{e.services.DirectionsRenderer.setMap(null)}a.ui.gmap._trigger(d,f===google.maps.DirectionsStatus.OK,b)})},displayStreetView:function(b,c){var d=a.ui.gmap.instances[this.element.attr("id")];if(!d.services.StreetViewPanorama){d.services.StreetViewPanorama=new google.maps.StreetViewPanorama(a.ui.gmap._unwrap(b),c)}d.map.setStreetView(d.services.StreetViewPanorama)},findMarker:function(b,c,d){a.each(this.getMarkers(),function(e,f){a.ui.gmap._trigger(d,f[b]===c,f)})},loadMetadata:function(b,c,d){if(b==="rdfa"){a.ui.gmap.rdfa(c,d)}else if(b==="microformat"){a.ui.gmap.microformat(c,d)}else if(b==="microdata"){a.ui.gmap.microdata(c,d)}},loadFusion:function(b,c){var d=a.ui.gmap.instances[this.element.attr("id")];if(!d.services.FusionTablesLayer){d.services.FusionTablesLayer=new google.maps.FusionTablesLayer(b,c)}d.services.FusionTablesLayer.setMap(this.getMap())},loadKML:function(b,c,d){var e=a.ui.gmap.instances[this.element.attr("id")];if(!e.services[b])e.services[b]=new google.maps.KmlLayer(c,jQuery.extend({map:e.map},d))},search:function(b,c){var d=a.ui.gmap.instances[this.element.attr("id")];if(!d.services.Geocoder){d.services.Geocoder=new google.maps.Geocoder}d.services.Geocoder.geocode(b,function(b,d){a.ui.gmap._trigger(c,d===google.maps.GeocoderStatus.OK,b)})},getMap:function(){return a.ui.gmap.instances[this.element.attr("id")].map},getMarkers:function(){return a.ui.gmap.instances[this.element.attr("id")].markers},getService:function(b){return a.ui.gmap.instances[this.element.attr("id")].services[b]},clearMarkers:function(){a.each(this.getMarkers(),function(a,b){google.maps.event.clearInstanceListeners(b);b.setMap(null);b=null});a.ui.gmap.instances[this.element.attr("id")].markers=[]},destroy:function(){this.clearMarkers();google.maps.event.clearInstanceListeners(this.getMap());a.each(a.ui.gmap.instances[this.element.attr("id")].services,function(a,b){b=null});a.Widget.prototype.destroy.call(this)}});a.extend(a.ui.gmap,{version:"2.0",instances:[],_trigger:function(b){if(a.isFunction(b)){b.apply(this,Array.prototype.slice.call(arguments,1))}},_unwrap:function b(a){if(!a){return null}else if(a instanceof jQuery){return a[0]}else if(a instanceof Object){return a}return document.getElementById(a)}})})(jQuery)
