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:"http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/images/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 Q=[];for(H=0;H<C.length;++H){I.addMarker(C[H],true,null,null,true)}C=Q}this.getStyles_=function(){return D};this.clearMarkers=function(){for(var Q=0;Q<K.length;++Q){if(typeof K[Q]!=="undefined"&&K[Q]!==null){K[Q].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(V,S,a,T,b){if(b!==true){if(!O(V)){C.push(V);return }}var W=a;var Y=T;var X=L.fromLatLngToDivPixel(V.getLatLng());if(typeof W!=="boolean"){W=false}if(typeof Y!=="object"||Y===null){Y=K}var R=Y.length;var Z=null;for(var U=R-1;U>=0;U--){Z=Y[U];var Q=Z.getCenter();if(Q===null){continue}Q=L.fromLatLngToDivPixel(Q);if(X.x>=Q.x-F&&X.x<=Q.x+F&&X.y>=Q.y-F&&X.y<=Q.y+F){Z.addMarker({isAdded:W,marker:V});if(!S){Z.redraw_()}return }}Z=new Cluster(this,B);Z.addMarker({isAdded:W,marker:V});if(!S){Z.redraw_()}Y.push(Z);if(Y!==K){K.push(Z)}};this.removeMarker=function(Q){for(var R=0;R<K.length;++R){if(K[R].remove(Q)){K[R].redraw_();return }}};this.redraw_=function(){var R=this.getClustersInViewport_();for(var Q=0;Q<R.length;++Q){R[Q].redraw_(true)}};this.getClustersInViewport_=function(){var S=[];var R=L.getBounds();for(var Q=0;Q<K.length;Q++){if(K[Q].isInBounds(R)){S.push(K[Q])}}return S};this.getMaxZoom_=function(){return E};this.getMap_=function(){return L};this.getGridSize_=function(){return F};this.getTotalMarkers=function(){var Q=0;for(var R=0;R<K.length;++R){Q+=K[R].getTotalMarkers()}return Q};this.getTotalClusters=function(){return K.length};this.resetViewport=function(){var W=this.getClustersInViewport_();var V=[];var U=0;for(var R=0;R<W.length;++R){var X=W[R];var Y=X.getCurrentZoom();if(Y===null){continue}var Z=L.getZoom();if(Z!==Y){var S=X.getMarkers();for(var Q=0;Q<S.length;++Q){var T={isAdded:false,marker:S[Q].marker};V.push(T)}X.clearMarkers();U++;for(Q=0;Q<K.length;++Q){if(X===K[Q]){K.splice(Q,1)}}}}N(V);this.redraw_()};this.addMarkers=function(R){for(var Q=0;Q<R.length;++Q){this.addMarker(R[Q],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(H){for(var I=0;I<G.length;++I){if(H===G[I].marker){if(G[I].isAdded){F.removeOverlay(G[I].marker)}G.splice(I,1);return true}}return false};this.getCurrentZoom=function(){return A};this.redraw_=function(J){if(!J&&!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){for(H=0;H<G.length;++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{for(H=0;H<G.length;++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)}for(var H=0;H<G.length;++H){if(G[H].isAdded){F.removeOverlay(G[H].marker)}}G=[]};this.getTotalMarkers=function(){return G.length}}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=new GOverlay();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(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+"cursor:pointer;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_;GEvent.addDomListener(G,"click",function(){var K=D.fromLatLngToDivPixel(F);var H=new GPoint(K.x-B,K.y+B);H=D.fromDivPixelToLatLng(H);var J=new GPoint(K.x+B,K.y-B);J=D.fromDivPixelToLatLng(J);var I=D.getBoundsZoomLevel(new GLatLngBounds(H,J),D.getSize());D.setCenter(F,I)});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"};
