var MarkerManager=(function(){function A(E,D){var C=this;C.map_=E;C.mapZoom_=E.getZoom();C.projection_=E.getCurrentMapType().getProjection();D=D||{};C.tileSize_=A.DEFAULT_TILE_SIZE_;var B=A.DEFAULT_MAX_ZOOM_;if(D.maxZoom!=undefined){B=D.maxZoom}C.maxZoom_=B;C.trackMarkers_=D.trackMarkers;var F;if(typeof D.borderPadding=="number"){F=D.borderPadding}else{F=A.DEFAULT_BORDER_PADDING_}C.swPadding_=new google.maps.Size(-F,F);C.nePadding_=new google.maps.Size(F,-F);C.borderPadding_=F;C.gridWidth_=[];C.grid_=[];C.grid_[B]=[];C.numMarkers_=[];C.numMarkers_[B]=0;google.maps.Event.bind(E,"moveend",C,C.onMapMoveEnd_);C.removeOverlay_=function(G){E.removeOverlay(G);C.shownMarkers_--};C.addOverlay_=function(G){E.addOverlay(G);C.shownMarkers_++};C.resetManager_();C.shownMarkers_=0;C.shownBounds_=C.getMapGridBounds_()}A.DEFAULT_TILE_SIZE_=1024;A.DEFAULT_MAX_ZOOM_=17;A.DEFAULT_BORDER_PADDING_=100;A.MERCATOR_ZOOM_LEVEL_ZERO_RANGE=256;A.prototype.resetManager_=function(){var D=this;var B=A.MERCATOR_ZOOM_LEVEL_ZERO_RANGE;for(var C=0;C<=D.maxZoom_;++C){D.grid_[C]=[];D.numMarkers_[C]=0;D.gridWidth_[C]=Math.ceil(B/D.tileSize_);B<<=1}};A.prototype.clearMarkers=function(){var B=this;B.processAll_(B.shownBounds_,B.removeOverlay_);B.resetManager_()};A.prototype.getTilePoint_=function(D,C,E){var B=this.projection_.fromLatLngToPixel(D,C);return new google.maps.Point(Math.floor((B.x+E.width)/this.tileSize_),Math.floor((B.y+E.height)/this.tileSize_))};A.prototype.addMarkerBatch_=function(F,H,C){var G=F.getPoint();if(this.trackMarkers_){google.maps.Event.bind(F,"changed",this,this.onMarkerMoved_)}var D=this.getTilePoint_(G,C,google.maps.Size.ZERO);for(var E=C;E>=H;E--){var B=this.getGridCellCreate_(D.x,D.y,E);B.push(F);D.x=D.x>>1;D.y=D.y>>1}};A.prototype.isGridPointVisible_=function(C){var G=this;var F=G.shownBounds_.minY<=C.y&&C.y<=G.shownBounds_.maxY;var B=G.shownBounds_.minX;var D=B<=C.x&&C.x<=G.shownBounds_.maxX;if(!D&&B<0){var E=G.gridWidth_[G.shownBounds_.z];D=B+E<=C.x&&C.x<=E-1}return F&&D};A.prototype.onMarkerMoved_=function(D,B,C){var H=this;var J=H.maxZoom_;var E=false;var G=H.getTilePoint_(B,J,google.maps.Size.ZERO);var F=H.getTilePoint_(C,J,google.maps.Size.ZERO);while(J>=0&&(G.x!=F.x||G.y!=F.y)){var I=H.getGridCellNoCreate_(G.x,G.y,J);if(I){if(H.removeFromArray(I,D)){H.getGridCellCreate_(F.x,F.y,J).push(D)}}if(J==H.mapZoom_){if(H.isGridPointVisible_(G)){if(!H.isGridPointVisible_(F)){H.removeOverlay_(D);E=true}}else{if(H.isGridPointVisible_(F)){H.addOverlay_(D);E=true}}}G.x=G.x>>1;G.y=G.y>>1;F.x=F.x>>1;F.y=F.y>>1;--J}if(E){H.notifyListeners_()}};A.prototype.removeMarker=function(G){var F=this;var E=F.maxZoom_;var H=false;var C=G.getPoint();var D=F.getTilePoint_(C,E,google.maps.Size.ZERO);while(E>=0){var B=F.getGridCellNoCreate_(D.x,D.y,E);if(B){F.removeFromArray(B,G)}if(E==F.mapZoom_){if(F.isGridPointVisible_(D)){F.removeOverlay_(G);H=true}}D.x=D.x>>1;D.y=D.y>>1;--E}if(H){F.notifyListeners_()}};A.prototype.addMarkers=function(E,F,D){var B=this.getOptMaxZoom_(D);for(var C=E.length-1;C>=0;C--){this.addMarkerBatch_(E[C],F,B)}this.numMarkers_[F]+=E.length};A.prototype.getOptMaxZoom_=function(B){return B!=undefined?B:this.maxZoom_};A.prototype.getMarkerCount=function(C){var B=0;for(var D=0;D<=C;D++){B+=this.numMarkers_[D]}return B};A.prototype.addMarker=function(F,G,D){var E=this;var B=this.getOptMaxZoom_(D);E.addMarkerBatch_(F,G,B);var C=E.getTilePoint_(F.getPoint(),E.mapZoom_,google.maps.Size.ZERO);if(E.isGridPointVisible_(C)&&G<=E.shownBounds_.z&&E.shownBounds_.z<=B){E.addOverlay_(F);E.notifyListeners_()}this.numMarkers_[G]++};google.maps.Bounds.prototype.containsPoint=function(B){var C=this;return(C.minX<=B.x&&C.maxX>=B.x&&C.minY<=B.y&&C.maxY>=B.y)};A.prototype.getGridCellCreate_=function(B,G,F){var D=this.grid_[F];if(B<0){B+=this.gridWidth_[F]}var C=D[B];if(!C){C=D[B]=[];return C[G]=[]}var E=C[G];if(!E){return C[G]=[]}return E};A.prototype.getGridCellNoCreate_=function(B,F,E){var D=this.grid_[E];if(B<0){B+=this.gridWidth_[E]}var C=D[B];return C?C[F]:undefined};A.prototype.getGridBounds_=function(E,J,H,I){J=Math.min(J,this.maxZoom_);var B=E.getSouthWest();var F=E.getNorthEast();var G=this.getTilePoint_(B,J,H);var D=this.getTilePoint_(F,J,I);var K=this.gridWidth_[J];if(F.lng()<B.lng()||D.x<G.x){G.x-=K}if(D.x-G.x+1>=K){G.x=0;D.x=K-1}var C=new google.maps.Bounds([G,D]);C.z=J;return C};A.prototype.getMapGridBounds_=function(){var B=this;return B.getGridBounds_(B.map_.getBounds(),B.mapZoom_,B.swPadding_,B.nePadding_)};A.prototype.onMapMoveEnd_=function(){var B=this;B.objectSetTimeout_(this,this.updateMarkers_,0)};A.prototype.objectSetTimeout_=function(C,D,B){return window.setTimeout(function(){D.call(C)},B)};A.prototype.refresh=function(){var B=this;if(B.shownMarkers_>0){B.processAll_(B.shownBounds_,B.removeOverlay_)}B.processAll_(B.shownBounds_,B.addOverlay_);B.notifyListeners_()};A.prototype.updateMarkers_=function(){var C=this;C.mapZoom_=this.map_.getZoom();var B=C.getMapGridBounds_();if(B.equals(C.shownBounds_)&&B.z==C.shownBounds_.z){return }if(B.z!=C.shownBounds_.z){C.processAll_(C.shownBounds_,C.removeOverlay_);C.processAll_(B,C.addOverlay_)}else{C.rectangleDiff_(C.shownBounds_,B,C.removeCellMarkers_);C.rectangleDiff_(B,C.shownBounds_,C.addCellMarkers_)}C.shownBounds_=B;C.notifyListeners_()};A.prototype.notifyListeners_=function(){google.maps.Event.trigger(this,"changed",this.shownBounds_,this.shownMarkers_)};A.prototype.processAll_=function(C,D){for(var B=C.minX;B<=C.maxX;B++){for(var E=C.minY;E<=C.maxY;E++){this.processCellMarkers_(B,E,C.z,D)}}};A.prototype.processCellMarkers_=function(C,G,F,E){var B=this.getGridCellNoCreate_(C,G,F);if(B){for(var D=B.length-1;D>=0;D--){E(B[D])}}};A.prototype.removeCellMarkers_=function(B,D,C){this.processCellMarkers_(B,D,C,this.removeOverlay_)};A.prototype.addCellMarkers_=function(B,D,C){this.processCellMarkers_(B,D,C,this.addOverlay_)};A.prototype.rectangleDiff_=function(C,B,E){var D=this;D.rectangleDiffCoords(C,B,function(F,G){E.apply(D,[F,G,C.z])})};A.prototype.rectangleDiffCoords=function(C,B,L){var G=C.minX;var N=C.minY;var I=C.maxX;var E=C.maxY;var F=B.minX;var M=B.minY;var H=B.maxX;var D=B.maxY;for(var K=G;K<=I;K++){for(var J=N;J<=E&&J<M;J++){L(K,J)}for(var J=Math.max(D+1,N);J<=E;J++){L(K,J)}}for(var J=Math.max(N,M);J<=Math.min(E,D);J++){for(var K=Math.min(I+1,F)-1;K>=G;K--){L(K,J)}for(var K=Math.max(G,H+1);K<=I;K++){L(K,J)}}};A.prototype.removeFromArray=function(F,D,E){var B=0;for(var C=0;C<F.length;++C){if(F[C]===D||(E&&F[C]==D)){F.splice(C--,1);B++}}return B};window.MarkerManager=A});var LabeledMarker=(function(){function A(C,B){this.latlng_=C;this.opts_=B;this.labelText_=B.labelText||"";this.labelClass_=B.labelClass||"LabeledMarker_markerLabel";this.labelOffset_=B.labelOffset||new google.maps.Size(0,0);this.clickable_=B.clickable||true;this.title_=B.title||"";this.labelVisibility_=true;if(B.draggable){B.draggable=false}google.maps.Marker.apply(this,arguments)}A.prototype=new google.maps.Marker(new google.maps.LatLng(0,0));A.prototype.initialize=function(E){google.maps.Marker.prototype.initialize.apply(this,arguments);this.map_=E;this.div_=document.createElement("div");this.div_.className=this.labelClass_;this.div_.innerHTML=this.labelText_;this.div_.style.position="absolute";this.div_.style.cursor="pointer";this.div_.title=this.title_;E.getPane(G_MAP_MARKER_PANE).appendChild(this.div_);if(this.clickable_){function B(H,G){return function(){google.maps.Event.trigger(H,G)}}var F=["click","dblclick","mousedown","mouseup","mouseover","mouseout"];for(var D=0;D<F.length;D++){var C=F[D];google.maps.Event.addDomListener(this.div_,C,B(this,C))}}};A.prototype.redraw=function(B){google.maps.Marker.prototype.redraw.apply(this,arguments);var C=this.map_.fromLatLngToDivPixel(this.latlng_);var D=google.maps.Overlay.getZIndex(this.latlng_.lat());this.div_.style.left=(C.x+this.labelOffset_.width)+"px";this.div_.style.top=(C.y+this.labelOffset_.height)+"px";this.div_.style.zIndex=D};A.prototype.remove=function(){google.maps.Event.clearInstanceListeners(this.div_);if(this.div_.outerHTML){this.div_.outerHTML=""}if(this.div_.parentNode){this.div_.parentNode.removeChild(this.div_)}this.div_=null;google.maps.Marker.prototype.remove.apply(this,arguments)};A.prototype.copy=function(){return new A(this.latlng_,this.opt_opts_)};A.prototype.show=function(){google.maps.Marker.prototype.show.apply(this,arguments);if(this.labelVisibility_){this.showLabel()}else{this.hideLabel()}};A.prototype.hide=function(){google.maps.Marker.prototype.hide.apply(this,arguments);this.hideLabel()};A.prototype.setLabelVisibility=function(B){this.labelVisibility_=B;if(!this.isHidden()){if(this.labelVisibility_){this.showLabel()}else{this.hideLabel()}}};A.prototype.getLabelVisibility=function(){return this.labelVisibility_};A.prototype.hideLabel=function(){this.div_.style.visibility="hidden"};A.prototype.showLabel=function(){this.div_.style.visibility="visible"};window.LabeledMarker=A});Jamendo.geocode4=function(G,C,F,B,D){var A=[];var E={};if(!G){return }if(G){level=0;A.push(G);E["country"]=G}if(G&&C){level=1;A.push(C);E["state"]=C}if(G&&F){level=3;A.push(F);E["city"]=F}if(G&&F&&B){level=4;A.push(B);E["address"]=B}E["type"]=(["country","state","city","address"])[level];E["hascoords"]=1;Jamendo.get2("coords/location/json/",E,function(I){if(I.length==0){var H=A.reverse().join(", ");var J=new google.maps.ClientGeocoder();J.getLatLng(H,function(K){D(K,level)})}else{D(new google.maps.LatLng(I[0].lat,I[0].lng),level)}})}