var overlap=20;function IconOverlay(c,b,a){this.point=c;this.icon=b;this.opts=a;this.image=b.image;this.shadow=b.shadow;this.anchor=b.iconAnchor;this.hidden=false;a=a||{};if(a.title){this.title=a.title;}if(a.mouseoverIcon){this.mouseoverIcon=a.mouseoverIcon;}}IconOverlay.prototype=new GOverlay();IconOverlay.prototype.initialize=function(c){var a=document.createElement("img");a.style.position="absolute";a.src=this.image;a.className="magnifier";try{a.style.cursor="pointer";}catch(b){}GEvent.bindDom(a,"click",this,this._onClick);GEvent.bindDom(a,"mouseover",this,this._onMouseOver);GEvent.bindDom(a,"mouseout",this,this._onMouseOut);c.getPane(G_MAP_MARKER_PANE).appendChild(a);this.map_=c;this.img_=a;if(this.title){this._setTooltip(this.title);}};IconOverlay.prototype.remove=function(){this.img_.parentNode.removeChild(this.img_);GEvent.clearInstanceListeners(this.img_);};IconOverlay.prototype.copy=function(){return new IconOverlay(this.point,this.icon,this.opts);};IconOverlay.prototype.redraw=function(a){if(!a){return;}var b=this.map_.fromLatLngToDivPixel(this.point);this.img_.style.left=(b.x-this.anchor.x)+"px";this.img_.style.top=(b.y-this.anchor.y)+"px";};IconOverlay.prototype.show=function(){this.img_.style.display="";this.hidden=false;};IconOverlay.prototype.hide=function(){this.img_.style.display="none";this.hidden=true;};IconOverlay.prototype.isHidden=function(){return this.hidden;};IconOverlay.prototype._setTooltip=function(a){if(window.ddrivetip&&window.hideddrivetip){GEvent.addListener(this,"mouseover",function(){ddrivetip(a);});GEvent.addListener(this,"mouseout",hideddrivetip);}else{this.title=a;this.img_.title=a;}};IconOverlay.prototype.setIcon=function(a){this.image=a.image;this.anchor=a.iconAnchor;this.img_.src=this.image;this.redraw(true);};IconOverlay.prototype.setPoint=function(a){this.point=a;this.redraw(true);};IconOverlay.prototype.getPoint=function(){return this.point;};IconOverlay.prototype.getLatLng=function(){return this.point;};IconOverlay.prototype.getIcon=function(){return this.icon;};IconOverlay.prototype._onClick=function(){GEvent.trigger(this,"click",this);};IconOverlay.prototype._onMouseOver=function(){if(this.mouseoverIcon){this.setIcon(this.mouseoverIcon);}GEvent.trigger(this,"mouseover",this);};IconOverlay.prototype._onMouseOut=function(){if(this.mouseoverIcon){this.setIcon(this.icon);}GEvent.trigger(this,"mouseout",this);};function ClusterMarker(b,a){this._map=b;this._mapMarkers=[];this._clusterMarkers=[];if(typeof(a)=="undefined"){a={};}this.fitMapToMarkers=(a.fitMapToMarkers===true);if(a.fitMapMaxZoom){this.fitMapMaxZoom=a.fitMapMaxZoom;}this.clusterMaxZoom=(a.clusterMaxZoom)?a.clusterMaxZoom:14;if(a.markers){this.addMarkers(a.markers);}this.borderPadding=(a.borderPadding)?a.borderPadding:256;this.intersectPadding=(a.intersectPadding)?a.intersectPadding:0;this.clusteringEnabled=(a.clusteringEnabled===false)?false:true;if(a.clusterIcon){this._clusterIcon=a.clusterIcon;}else{this._clusterIcon=new GIcon();this._clusterIcon.image="/images/zoom.png";this._clusterIcon.shadow="/images/shadow-zoom.png";this._clusterIcon.shadowSize=new GSize(42,29);this._clusterIcon.iconSize=new GSize(27,29);this._clusterIcon.iconAnchor=new GPoint(14,14);}this._cancelMoveEnd=false;GEvent.bind(this._map,"moveend",this,this._moveEnd);GEvent.bind(this._map,"zoomend",this,this._zoomEnd);GEvent.bind(this._map,"maptypechanged",this,this._zoomEnd);}ClusterMarker.prototype._zoomEnd=function(){for(var a=this._mapMarkers.length;--a>=0;){if(this._mapMarkers[a]._isVisible===-1){this._mapMarkers[a]._isVisible=0;}}this.refresh(this._clusterMarkers.length);};ClusterMarker.prototype._moveEnd=function(){if(!this._cancelMoveEnd){this.refresh(0);}else{this._cancelMoveEnd=false;}};ClusterMarker.prototype.addMarkers=function(b){this._mapMarkers=b;this._mapMarkers.sort(function(c,d){return(c.getLatLng().lat()-d.getLatLng().lat());});for(var a=b.length;--a>=0;){this._mapMarkers[a]._isVisible=0;}};ClusterMarker.prototype.refresh=function(a){a=(a>0)?a:0;var m=this._map.getZoom();var s=this._map.getCurrentMapType().getProjection();var d=this._map.getBounds();var c=s.fromLatLngToPixel(d.getSouthWest(),m);var r=s.fromLatLngToPixel(d.getNorthEast(),m);var x=new GPoint(c.x-this.borderPadding,c.y+this.borderPadding);var n=new GPoint(r.x+this.borderPadding,r.y-this.borderPadding);d.extend(s.fromPixelToLatLng(x,m));d.extend(s.fromPixelToLatLng(n,m));if(this.clusteringEnabled&&m<=this.clusterMaxZoom){var f=[];var l=this._mapMarkers.length;for(g=this._mapMarkers.length;--g>=0;){var b=this._mapMarkers[g];if(b._isVisible<0){}else{if(d.containsLatLng(b.getLatLng())){if(l>g){f[g]=s.fromLatLngToPixel(b.getLatLng(),m);}var e=[],v=b.getLatLng().lat(),w=b.getLatLng().lng();var u=new GLatLngBounds();u.extend(b.getLatLng());for(var h=g;--h>=0;){var q=this._mapMarkers[h];if(l>h){f[h]=s.fromLatLngToPixel(q.getLatLng(),m);l=h;}if(f[g].y<f[h].y-overlap){break;}if(q._isVisible>=0&&f[h].x>=f[g].x-overlap&&f[h].x<=f[g].x+overlap){if(q._isVisible==1){this._map.removeOverlay(q);}q._isVisible=-1;e.push(h);v+=q.getLatLng().lat();w+=q.getLatLng().lng();u.extend(q.getLatLng());}}if(e.length!==0){e.push(g);if(b._isVisible===1){this._map.removeOverlay(b);}b._isVisible=-1;v=v/e.length;w=w/e.length;var o;if(v==b.getLatLng().lat()&&w==b.getLatLng().lng()){o="Click for details of the "+e.length+" holidays at this location.";}else{o="Click to zoom in for a closer look at the "+e.length+" holidays at this location.";}var t;if(a>0){a--;t=this._clusterMarkers[a];t.setPoint(new GLatLng(v,w));t._setTooltip(o);}else{t=new IconOverlay(new GLatLng(v,w),this._clusterIcon,{title:o});GEvent.addListener(t,"click",function(){zoom(t,"in");});this._map.addOverlay(t);this._clusterMarkers.push(t);}t.clusterGroup=e;}else{if(b._isVisible===0){this._map.addOverlay(b);b._isVisible=1;}}}else{if(b._isVisible===1){this._map.removeOverlay(b);b._isVisible=0;}}}}}else{for(var g=this._mapMarkers.length-1;g>=0;g--){var b=this._mapMarkers[g];if(b._isVisible===0&&d.containsLatLng(b.getLatLng())){this._map.addOverlay(b);b._isVisible=1;}else{if(b._isVisible===1&&!d.containsLatLng(b.getLatLng())){this._map.removeOverlay(b);b._isVisible=0;}}}}if(a>0){for(g=a;--g>=0;){this._map.removeOverlay(this._clusterMarkers[g]);}this._clusterMarkers.splice(0,a);}};ClusterMarker.prototype.removeMarkers=function(){for(var a=this._mapMarkers.length;--a>=0;){if(this._mapMarkers[a]._isVisible==1){this._map.removeOverlay(this._mapMarkers[a]);}delete this._mapMarkers[a]._isVisible;}this._mapMarkers=[];for(var a=this._clusterMarkers.length;--a>=0;){this._map.removeOverlay(this._clusterMarkers[a]);}this._clusterMarkers=[];};
