(function($){var geocoder=new google.maps.Geocoder();function MyOverlay(map){this.setMap(map);};MyOverlay.prototype=new google.maps.OverlayView();MyOverlay.prototype.onAdd=function(){};MyOverlay.prototype.onRemove=function(){};MyOverlay.prototype.draw=function(){};$.goMap={};$.fn.goMap=function(options){return this.each(function(){var goMap=$(this).data('goMap');if(!goMap){var goMapBase=$.extend(true,{},$.goMapBase);$(this).data('goMap',goMapBase.init(this,options));$.goMap=goMapBase;}else{$.goMap=goMap;}});};$.goMapBase={defaults:{address:'',latitude:56.9,longitude:24.1,zoom:4,delay:200,hideByClick:true,oneInfoWindow:true,prefixId:'gomarker',groupId:'gogroup',navigationControl:true,navigationControlOptions:{position:'TOP_LEFT',style:'DEFAULT'},mapTypeControl:true,mapTypeControlOptions:{position:'TOP_RIGHT',style:'DEFAULT'},scaleControl:false,scrollwheel:true,directions:false,directionsResult:null,disableDoubleClickZoom:false,streetViewControl:false,markers:[],maptype:'HYBRID',html_prepend:'
',html_append:'
',addMarker:false},map:null,count:0,markers:[],tmpMarkers:[],geoMarkers:[],lockGeocode:false,bounds:null,overlay:null,mapId:null,opts:null,centerLatLng:null,init:function(el,options){var opts=$.extend({},$.goMapBase.defaults,options);this.mapId=$(el);this.opts=opts;if(opts.address)this.geocode({address:opts.address,center:true});else if($.isArray(opts.markers)&&opts.markers.length>0){if(opts.markers[0].address)this.geocode({address:opts.markers[0].address,center:true});else
this.centerLatLng=new google.maps.LatLng(opts.markers[0].latitude,opts.markers[0].longitude);}else
this.centerLatLng=new google.maps.LatLng(opts.latitude,opts.longitude);var myOptions={center:this.centerLatLng,disableDoubleClickZoom:opts.disableDoubleClickZoom,mapTypeControl:opts.mapTypeControl,streetViewControl:opts.streetViewControl,mapTypeControlOptions:{position:google.maps.ControlPosition[opts.mapTypeControlOptions.position.toUpperCase()],style:google.maps.MapTypeControlStyle[opts.mapTypeControlOptions.style.toUpperCase()]},mapTypeId:google.maps.MapTypeId[opts.maptype.toUpperCase()],styles:[{featureType:"poi.business",elementType:"labels",stylers:[{visibility:opts.places}]}],navigationControl:opts.navigationControl,navigationControlOptions:{position:google.maps.ControlPosition[opts.navigationControlOptions.position.toUpperCase()],style:google.maps.NavigationControlStyle[opts.navigationControlOptions.style.toUpperCase()]},scaleControl:opts.scaleControl,scrollwheel:opts.scrollwheel,zoom:opts.zoom};this.map=new google.maps.Map(el,myOptions);this.overlay=new MyOverlay(this.map);for(var j=0,l=opts.markers.length;j0&&!this.lockGeocode){this.lockGeocode=true;var current=this.geoMarkers.splice(0,1);this.geocode({address:current[0].address},current[0]);}else if(this.lockGeocode){var goMap=this;setTimeout(function(){goMap.geoMarker();},this.opts.delay);}},setMap:function(options){delete options.mapTypeId;if(options.address){this.geocode({address:options.address,center:true});delete options.address;}else if(options.latitude&&options.longitude){options.center=new google.maps.LatLng(options.latitude,options.longitude);delete options.longitude;delete options.latitude;}if(options.mapTypeControlOptions&&options.mapTypeControlOptions.position)options.mapTypeControlOptions.position=google.maps.ControlPosition[options.mapTypeControlOptions.position.toUpperCase()];if(options.mapTypeControlOptions&&options.mapTypeControlOptions.style)options.mapTypeControlOptions.style=google.maps.MapTypeControlStyle[options.mapTypeControlOptions.style.toUpperCase()];if(options.navigationControlOptions&&options.navigationControlOptions.position)options.navigationControlOptions.position=google.maps.ControlPosition[options.navigationControlOptions.position.toUpperCase()];if(options.navigationControlOptions&&options.navigationControlOptions.style)options.navigationControlOptions.style=google.maps.NavigationControlStyle[options.navigationControlOptions.style.toUpperCase()];this.map.setOptions(options);},getMap:function(){return this.map;},createListener:function(type,event,data){var target;if(typeof type!='object')type={type:type};if(type.type=='map')target=this.map;else if(type.type=='marker'&&type.marker)target=$(this.mapId).data(type.marker);else if(type.type=='info'&&type.marker)target=$(this.mapId).data(type.marker+'info');if(target)return google.maps.event.addListener(target,event,data);else if((type.type=='marker'||type.type=='info')&&this.getMarkerCount()!=this.getTmpMarkerCount())var goMap=this;setTimeout(function(){goMap.createListener(type,event,data);},this.opts.delay);},removeListener:function(listener){google.maps.event.removeListener(listener);},setInfoWindow:function(marker,html){var goMap=this;html.content=goMap.opts.html_prepend+html.content+goMap.opts.html_append;var infowindow=new google.maps.InfoWindow(html);infowindow.show=false;$(goMap.mapId).data(marker.id+'info',infowindow);if(html.popup){goMap.openWindow(infowindow,marker,html);infowindow.show=true;}google.maps.event.addListener(marker,'click',function(){if(infowindow.show&&goMap.opts.hideByClick){infowindow.close();infowindow.show=false;}else{goMap.openWindow(infowindow,marker,html);infowindow.show=true;}});},openWindow:function(infowindow,marker,html){if(this.opts.oneInfoWindow)this.clearInfo();if(html.ajax){infowindow.open(this.map,marker);$.ajax({url:html.ajax,success:function(html){infowindow.setContent(html);}});}else if(html.id){infowindow.setContent($(html.id).html());infowindow.open(this.map,marker);}else
infowindow.open(this.map,marker);},setInfo:function(id,text){var info=$(this.mapId).data(id+'info');if(typeof text=='object')info.setOptions(text);else
info.setContent(text);},getInfo:function(id,hideDiv){var info=$(this.mapId).data(id+'info').getContent();if(hideDiv)return $(info).html();else
return info;},clearInfo:function(){for(var i=0,l=this.markers.length;i-1){this.tmpMarkers.splice(index,1);current=this.markers.splice(index,1);var markerId=current[0];var marker=$(this.mapId).data(markerId);var info=$(this.mapId).data(markerId+'info');marker.setVisible(false);marker.setMap(null);$(this.mapId).removeData(markerId);if(info){info.close();info.show=false;$(this.mapId).removeData(markerId+'info');}return true;}return false;},clearMarkers:function(){for(var i=0,l=this.markers.length;i