function MarkerClusterer(B,G,A){var K=[];var L=B;var E=null;var I=this;var F=60;var P=[53,56,66,78,90];var D=[];var C=[];var J=null;var H=0;for(H=1;H<=5;++H){D.push({url:"/img/map/m"+H+".png",height:P[H-1],width:P[H-1]})}if(typeof A==="object"&&A!==null){if(typeof A.gridSize==="number"&&A.gridSize>0){F=A.gridSize}if(typeof A.maxZoom==="number"){E=A.maxZoom}if(typeof A.styles==="object"&&A.styles!==null&&A.styles.length!==0){D=A.styles}}function M(){if(C.length===0){return }var R=[];var Q=C.length;for(H=0;H<Q;++H){I.addMarker(C[H],true,null,null,true)}C=R}this.getStyles_=function(){return D};this.clearMarkers=function(){var Q=K.length;for(var R=0;R<Q;++R){if(typeof K[R]!=="undefined"&&K[R]!==null){K[R].clearMarkers()}}K=[];C=[];GEvent.removeListener(J)};function O(Q){return L.getBounds().containsLatLng(Q.getLatLng())}function N(T){var Q=T.length;var S=[];for(var R=Q-1;R>=0;--R){I.addMarker(T[R].marker,true,T[R].isAdded,S,true)}M()}this.addMarker=function(U,R,Z,S,a){if(a!==true){if(!O(U)){C.push(U);return }}var V=Z;var X=S;var W=L.fromLatLngToDivPixel(U.getLatLng());if(typeof V!=="boolean"){V=false}if(typeof X!=="object"||X===null){X=K}var T=X.length;var Y=null;while(T--){Y=X[T];var Q=Y.getCenter();if(Q===null){continue}Q=L.fromLatLngToDivPixel(Q);if(W.x>=Q.x-F&&W.x<=Q.x+F&&W.y>=Q.y-F&&W.y<=Q.y+F){Y.addMarker({isAdded:V,marker:U});if(!R){Y.redraw_()}return }}Y=new Cluster(this,B);Y.addMarker({isAdded:V,marker:U});if(!R){Y.redraw_()}X.push(Y);if(X!==K){K.push(Y)}};this.removeMarker=function(R){var Q=K.length;for(var S=0;S<Q;++S){if(K[S].remove(R)){K[S].redraw_();return }}};this.redraw_=function(){var S=this.getClustersInViewport_();var Q=S.length;for(var R=0;R<Q;++R){S[R].redraw_(true)}};this.getClustersInViewport_=function(){var T=[];var S=L.getBounds();var Q=K.length;for(var R=0;R<Q;R++){if(K[R].isInBounds(S)){T.push(K[R])}}return T};this.getMaxZoom_=function(){return E};this.getMap_=function(){return L};this.getGridSize_=function(){return F};this.setGridSize=function(Q){F=Q};this.getTotalMarkers=function(){var R=0;var Q=K.length;for(var S=0;S<Q;++S){R+=K[S].getTotalMarkers()}return R};this.getTotalClusters=function(){return K.length};this.resetViewport=function(){var Y=this.getClustersInViewport_();var X=[];var V=0;var W=Y.length;for(var S=0;S<W;++S){var a=Y[S];var b=a.getCurrentZoom();if(b===null){continue}var c=L.getZoom();if(c!==b){var T=a.getMarkers();var Z=T.length;for(var R=0;R<Z;++R){var U={isAdded:false,marker:T[R].marker};X.push(U)}a.clearMarkers();V++;var Q=K.length;for(R=0;R<Q;++R){if(a===K[R]){K.splice(R,1)}}}}N(X);this.redraw_()};this.addMarkers=function(S){var Q=S.length;for(var R=0;R<Q;++R){this.addMarker(S[R],true)}this.redraw_()};if(typeof G==="object"&&G!==null){this.addMarkers(G)}J=GEvent.addListener(L,"moveend",function(){I.resetViewport()})}function Cluster(C){var B=null;var G=[];var E=C;var F=C.getMap_();var D=null;var A=F.getZoom();this.getMarkers=function(){return G};this.isInBounds=function(L){if(B===null){return false}if(!L){L=F.getBounds()}var H=F.fromLatLngToDivPixel(L.getSouthWest());var N=F.fromLatLngToDivPixel(L.getNorthEast());var M=F.fromLatLngToDivPixel(B);var J=true;var I=C.getGridSize_();if(A!==F.getZoom()){var K=F.getZoom()-A;I=Math.pow(2,K)*I}if(N.x!==H.x&&(M.x+I<H.x||M.x-I>N.x)){J=false}if(J&&(M.y+I<N.y||M.y-I>H.y)){J=false}return J};this.getCenter=function(){return B};this.addMarker=function(H){if(B===null){B=H.marker.getLatLng()}G.push(H)};this.removeMarker=function(I){var H=G.length;for(var J=0;J<H;++J){if(I===G[J].marker){if(G[J].isAdded){F.removeOverlay(G[J].marker)}G.splice(J,1);return true}}return false};this.getCurrentZoom=function(){return A};this.redraw_=function(L){if(!L&&!this.isInBounds()){return }A=F.getZoom();var H=0;var I=C.getMaxZoom_();if(I===null){I=F.getCurrentMapType().getMaximumResolution()}if(A>=I||this.getTotalMarkers()===1){var K=G.length;for(H=0;H<K;++H){if(G[H].isAdded){if(G[H].marker.isHidden()){G[H].marker.show()}}else{F.addOverlay(G[H].marker);G[H].isAdded=true}}if(D!==null){D.hide()}}else{var J=G.length;for(H=0;H<J;++H){if(G[H].isAdded&&(!G[H].marker.isHidden())){G[H].marker.hide()}}if(D===null){D=new ClusterMarker_(B,this.getTotalMarkers(),E.getStyles_(),E.getGridSize_());F.addOverlay(D)}else{if(D.isHidden()){D.show()}D.redraw(true)}}};this.clearMarkers=function(){if(D!==null){F.removeOverlay(D)}var H=G.length;for(var I=0;I<H;++I){if(G[I].isAdded){F.removeOverlay(G[I].marker)}}G=[]};this.getTotalMarkers=function(){var J=0;var H=G.length;for(var I=0;I<H;++I){J+=G[I].marker.amount}return J}}function ClusterMarker_(F,D,C,E){var A=0;var B=D;while(B!==0){B=parseInt(B/10,10);A++}if(C.length<A){A=C.length}this.url_=C[A-1].url;this.height_=C[A-1].height;this.width_=C[A-1].width;this.textColor_=C[A-1].opt_textColor;this.anchor_=C[A-1].opt_anchor;this.latlng_=F;this.index_=A;this.styles_=C;this.text_=D;this.padding_=E}ClusterMarker_.prototype.initialize=function(D){this.map_=D;var G=document.createElement("div");var F=this.latlng_;var E=D.fromLatLngToDivPixel(F);E.x-=parseInt(this.width_/2,10);E.y-=parseInt(this.height_/2,10);var C="";if(document.all){C='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="'+this.url_+'");'}else{C="background:url("+this.url_+");"}if(this.height_>67){this.height_=66}if(this.width_>67){this.width_=66}if(typeof this.anchor_==="object"){if(typeof this.anchor_[0]==="number"&&this.anchor_[0]>0&&this.anchor_[0]<this.height_){C+="height:"+(this.height_-this.anchor_[0])+"px;padding-top:"+this.anchor_[0]+"px;"}else{C+="height:"+this.height_+"px;line-height:"+this.height_+"px;"}if(typeof this.anchor_[1]==="number"&&this.anchor_[1]>0&&this.anchor_[1]<this.width_){C+="width:"+(this.width_-this.anchor_[1])+"px;padding-left:"+this.anchor_[1]+"px;"}else{C+="width:"+this.width_+"px;text-align:center;"}}else{C+="height:"+this.height_+"px;line-height:"+this.height_+"px;";C+="width:"+this.width_+"px;text-align:center;"}var A=this.textColor_?this.textColor_:"black";G.style.cssText=C+";top:"+E.y+"px;left:"+E.x+"px;color:"+A+";position:absolute;font-size:11px;font-family:Arial,sans-serif;font-weight:bold";G.innerHTML=this.text_;D.getPane(G_MAP_MAP_PANE).appendChild(G);var B=this.padding_;this.div_=G};ClusterMarker_.prototype.remove=function(){this.div_.parentNode.removeChild(this.div_)};ClusterMarker_.prototype.copy=function(){return new ClusterMarker_(this.latlng_,this.index_,this.text_,this.styles_,this.padding_)};ClusterMarker_.prototype.redraw=function(A){if(!A){return }var B=this.map_.fromLatLngToDivPixel(this.latlng_);B.x-=parseInt(this.width_/2,10);B.y-=parseInt(this.height_/2,10);this.div_.style.top=B.y+"px";this.div_.style.left=B.x+"px"};ClusterMarker_.prototype.hide=function(){this.div_.style.display="none"};ClusterMarker_.prototype.show=function(){this.div_.style.display=""};ClusterMarker_.prototype.isHidden=function(){return this.div_.style.display==="none"};
