function MarkerClusterer(m,n,o){var p=[];var q=m;var r=null;var s=this;var t=25;var u=[53,56,66,78,90];var v=[];var w=[];var x=null;var i=0;for(i=1;i<=5;++i){v.push({'url':"core/googlemaps/images/cluster_m"+i+".png",'height':u[i-1],'width':u[i-1]})}if(typeof o==="object"&&o!==null){if(typeof o.gridSize==="number"&&o.gridSize>0){t=o.gridSize}if(typeof o.maxZoom==="number"){r=o.maxZoom}if(typeof o.styles==="object"&&o.styles!==null&&o.styles.length!==0){v=o.styles}}function addLeftMarkers_(){if(w.length===0){return}var a=[];for(i=0;i<w.length;++i){s.addMarker(w[i],true,null,null,true)}w=a}this.getStyles_=function(){return v};this.clearMarkers=function(){for(var i=0;i<p.length;++i){if(typeof p[i]!=="undefined"&&p[i]!==null){p[i].clearMarkers()}}p=[];w=[];GEvent.removeListener(x)};function isMarkerInViewport_(a){return q.getBounds().containsLatLng(a.getLatLng())}function reAddMarkers_(a){var b=a.length;var c=[];for(var i=b-1;i>=0;--i){s.addMarker(a[i].marker,true,a[i].isAdded,c,true)}addLeftMarkers_()}this.addMarker=function(a,b,c,d,e){if(e!==true){if(!isMarkerInViewport_(a)){w.push(a);return}}var f=c;var g=d;var h=q.fromLatLngToDivPixel(a.getLatLng());if(typeof f!=="boolean"){f=false}if(typeof g!=="object"||g===null){g=p}var j=g.length;var k=null;for(var i=j-1;i>=0;i--){k=g[i];var l=k.getCenter();if(l===null){continue}l=q.fromLatLngToDivPixel(l);if(h.x>=l.x-t&&h.x<=l.x+t&&h.y>=l.y-t&&h.y<=l.y+t){k.addMarker({'isAdded':f,'marker':a});if(!b){k.redraw_()}return}}k=new Cluster(this,m);k.addMarker({'isAdded':f,'marker':a});if(!b){k.redraw_()}g.push(k);if(g!==p){p.push(k)}};this.removeMarker=function(a){for(var i=0;i<p.length;++i){if(p[i].remove(a)){p[i].redraw_();return}}};this.redraw_=function(){var a=this.getClustersInViewport_();for(var i=0;i<a.length;++i){a[i].redraw_(true)}};this.getClustersInViewport_=function(){var a=[];var b=q.getBounds();for(var i=0;i<p.length;i++){if(p[i].isInBounds(b)){a.push(p[i])}}return a};this.getMaxZoom_=function(){return r};this.getMap_=function(){return q};this.getGridSize_=function(){return t};this.getTotalMarkers=function(){var a=0;for(var i=0;i<p.length;++i){a+=p[i].getTotalMarkers()}return a};this.getTotalClusters=function(){return p.length};this.resetViewport=function(){var a=this.getClustersInViewport_();var b=[];var c=0;for(var i=0;i<a.length;++i){var d=a[i];var e=d.getCurrentZoom();if(e===null){continue}var f=q.getZoom();if(f!==e){var g=d.getMarkers();for(var j=0;j<g.length;++j){var h={'isAdded':false,'marker':g[j].marker};b.push(h)}d.clearMarkers();c++;for(j=0;j<p.length;++j){if(d===p[j]){p.splice(j,1)}}}}reAddMarkers_(b);this.redraw_()};this.addMarkers=function(a){for(var i=0;i<a.length;++i){this.addMarker(a[i],true)}this.redraw_()};if(typeof n==="object"&&n!==null){this.addMarkers(n)}x=GEvent.addListener(q,"moveend",function(){s.resetViewport()})}function Cluster(h){var j=null;var k=[];var l=h;var m=h.getMap_();var n=null;var o=m.getZoom();this.getMarkers=function(){return k};this.isInBounds=function(a){if(j===null){return false}if(!a){a=m.getBounds()}var b=m.fromLatLngToDivPixel(a.getSouthWest());var c=m.fromLatLngToDivPixel(a.getNorthEast());var d=m.fromLatLngToDivPixel(j);var e=true;var f=h.getGridSize_();if(o!==m.getZoom()){var g=m.getZoom()-o;f=Math.pow(2,g)*f}if(c.x!==b.x&&(d.x+f<b.x||d.x-f>c.x)){e=false}if(e&&(d.y+f<c.y||d.y-f>b.y)){e=false}return e};this.getCenter=function(){return j};this.addMarker=function(a){if(j===null){j=a.marker.getLatLng()}k.push(a)};this.removeMarker=function(a){for(var i=0;i<k.length;++i){if(a===k[i].marker){if(k[i].isAdded){m.removeOverlay(k[i].marker)}k.splice(i,1);return true}}return false};this.getCurrentZoom=function(){return o};this.redraw_=function(a){if(!a&&!this.isInBounds()){return}o=m.getZoom();var i=0;var b=h.getMaxZoom_();if(b===null){b=m.getCurrentMapType().getMaximumResolution()}if(o>=b||this.getTotalMarkers()===1){for(i=0;i<k.length;++i){if(k[i].isAdded){if(k[i].marker.isHidden()){k[i].marker.show()}}else{m.addOverlay(k[i].marker);k[i].isAdded=true}}if(n!==null){n.hide()}}else{for(i=0;i<k.length;++i){if(k[i].isAdded&&(!k[i].marker.isHidden())){k[i].marker.hide()}}if(n===null){n=new ClusterMarker_(j,this.getTotalMarkers(),l.getStyles_(),l.getGridSize_());m.addOverlay(n)}else{if(n.isHidden()){n.show()}n.redraw(true)}}};this.clearMarkers=function(){if(n!==null){m.removeOverlay(n)}for(var i=0;i<k.length;++i){if(k[i].isAdded){m.removeOverlay(k[i].marker)}}k=[]};this.getTotalMarkers=function(){return k.length}}function ClusterMarker_(a,b,c,d){var e=0;var f=b;while(f!==0){f=parseInt(f/10,10);e++}if(c.length<e){e=c.length}this.url_=c[e-1].url;this.height_=c[e-1].height;this.width_=c[e-1].width;this.textColor_=c[e-1].opt_textColor;this.anchor_=c[e-1].opt_anchor;this.latlng_=a;this.index_=e;this.styles_=c;this.text_=b;this.padding_=d}ClusterMarker_.prototype=new GOverlay();ClusterMarker_.prototype.initialize=function(e){this.map_=e;var f=document.createElement("div");var g=this.latlng_;var h=e.fromLatLngToDivPixel(g);h.x-=parseInt(this.width_/2,10);h.y-=parseInt(this.height_/2,10);var i="";if(document.all){i='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="'+this.url_+'");'}else{i="background:url("+this.url_+");"}if(typeof this.anchor_==="object"){if(typeof this.anchor_[0]==="number"&&this.anchor_[0]>0&&this.anchor_[0]<this.height_){i+='height:'+(this.height_-this.anchor_[0])+'px;padding-top:'+this.anchor_[0]+'px;'}else{i+='height:'+this.height_+'px;line-height:'+this.height_+'px;'}if(typeof this.anchor_[1]==="number"&&this.anchor_[1]>0&&this.anchor_[1]<this.width_){i+='width:'+(this.width_-this.anchor_[1])+'px;padding-left:'+this.anchor_[1]+'px;'}else{i+='width:'+this.width_+'px;text-align:center;'}}else{i+='height:'+this.height_+'px;line-height:'+this.height_+'px;';i+='width:'+this.width_+'px;text-align:center;'}var j=this.textColor_?this.textColor_:'black';f.style.cssText=i+'cursor:pointer;top:'+h.y+"px;left:"+h.x+"px;color:"+j+";position:absolute;font-size:11px;"+'font-family:Arial,sans-serif;font-weight:bold';f.innerHTML=this.text_;e.getPane(G_MAP_MAP_PANE).appendChild(f);var k=this.padding_;GEvent.addDomListener(f,"click",function(){var a=e.fromLatLngToDivPixel(g);var b=new GPoint(a.x-k,a.y+k);b=e.fromDivPixelToLatLng(b);var c=new GPoint(a.x+k,a.y-k);c=e.fromDivPixelToLatLng(c);var d=e.getBoundsZoomLevel(new GLatLngBounds(b,c),e.getSize());e.setCenter(g,d)});this.div_=f};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"};
