function MarkerClusterer(b,g,a){var l=[];var m=b;var e=null;var j=this;var f=60;var r=[53,56,66,78,90];var d=[];var c=[];var k=null;var o=2;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:r[h-1],width:r[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}if(typeof a.minClusterSize==="number"&&a.minClusterSize>2){o=a.minClusterSize}}function n(){if(c.length===0){return}var i=[];for(h=0;h<c.length;++h){j.addMarker(c[h],true,null,null,true)}c=i}this.getStyles_=function(){return d};this.clearMarkers=function(){for(var s=0;s<l.length;++s){if(typeof l[s]!=="undefined"&&l[s]!==null){l[s].clearMarkers()}}l=[];c=[];GEvent.removeListener(k)};function q(i){return m.getBounds().containsLatLng(i.getLatLng())}function p(v){var s=v.length;var u=[];for(var t=s-1;t>=0;--t){j.addMarker(v[t].marker,true,v[t].isAdded,u,true)}n()}this.addMarker=function(x,u,C,v,D){if(D!==true){if(!q(x)){c.push(x);return}}var y=C;var A=v;var z=m.fromLatLngToDivPixel(x.getLatLng());if(typeof y!=="boolean"){y=false}if(typeof A!=="object"||A===null){A=l}var t=A.length;var B=null;for(var w=t-1;w>=0;w--){B=A[w];var s=B.getCenter();if(s===null){continue}s=m.fromLatLngToDivPixel(s);if(z.x>=s.x-f&&z.x<=s.x+f&&z.y>=s.y-f&&z.y<=s.y+f){B.addMarker({isAdded:y,marker:x});if(!u){B.redraw_()}return}}B=new Cluster(this,b);B.addMarker({isAdded:y,marker:x});if(!u){B.redraw_()}A.push(B);if(A!==l){l.push(B)}};this.removeMarker=function(s){for(var t=0;t<l.length;++t){if(l[t].remove(s)){l[t].redraw_();return}}};this.redraw_=function(){var t=this.getClustersInViewport_();for(var s=0;s<t.length;++s){t[s].redraw_(true)}};this.getClustersInViewport_=function(){var u=[];var t=m.getBounds();for(var s=0;s<l.length;s++){if(l[s].isInBounds(t)){u.push(l[s])}}return u};this.getMaxZoom_=function(){return e};this.getMap_=function(){return m};this.getGridSize_=function(){return f};this.getMinClusterSize_=function(){return o};this.getTotalMarkers=function(){var s=0;for(var t=0;t<l.length;++t){s+=l[t].getTotalMarkers()}return s};this.getTotalClusters=function(){return l.length};this.resetViewport=function(){var y=this.getClustersInViewport_();var x=[];var w=0;for(var t=0;t<y.length;++t){var z=y[t];var A=z.getCurrentZoom();if(A===null){continue}var B=m.getZoom();if(B!==A){var u=z.getMarkers();for(var s=0;s<u.length;++s){var v={isAdded:false,marker:u[s].marker};x.push(v)}z.clearMarkers();w++;for(s=0;s<l.length;++s){if(z===l[s]){l.splice(s,1)}}}}p(x);this.redraw_()};this.addMarkers=function(t){for(var s=0;s<t.length;++s){this.addMarker(t[s],true)}this.redraw_()};if(typeof g==="object"&&g!==null){this.addMarkers(g)}k=GEvent.addListener(m,"moveend",function(){j.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 j=0;j<g.length;++j){if(h===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 j=c.getMaxZoom_();var k=c.getMinClusterSize_();if(j===null){j=f.getCurrentMapType().getMaximumResolution()}if(a>=j||(this.getTotalMarkers()>=1&&this.getTotalMarkers()<k)){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"};