(function(){
	var d=true,f=null,i=false;
	function j(a){
		return function(b){
			this[a]=b}
	}
	
	function k(a){
		return function(){
			return this[a]}
		}
		var l;
		function m(a,b,c){
			this.extend(m,google.maps.OverlayView);
			this.b=a;
			this.a=[];
			this.f=[];
			this.ca=[53,56,66,78,90];
			this.j=[];
			this.A=i;
			c=c||{};

			this.g=c.gridSize||60;
			this.l=c.minimumClusterSize||2;
			this.Y=c.maxZoom||f;
			this.j=c.styles||[];
			this.X=c.imagePath||this.Q;
			this.W=c.imageExtension||this.P;
			this.O=d;

			if(c.zoomOnClick!=undefined)this.O=c.zoomOnClick;
			
			this.r=i;
			if(c.averageCenter!=undefined)this.r=c.averageCenter;

			n(this);
			
			this.setMap(a);
			this.J=this.b.getZoom();
			var e=this;

			google.maps.event.addListener(this.b,"zoom_changed",function(){
				var g=e.b.mapTypes[e.b.getMapTypeId()].maxZoom,o=e.b.getZoom();
				if(!(o<0||o>g))if(e.J!=o){
					e.J=e.b.getZoom();
					e.m()
				}
			});

			google.maps.event.addListener(this.b,"idle",function(){
				e.i()
			});

			b&&b.length&&this.C(b,i)}l=m.prototype;

			l.Q="css/maps/clusterer/m";
			l.P="png";
			
			l.extend=function(a,b){
				return function(c){
					for(var e in c.prototype)this.prototype[e]=c.prototype[e];
					return this
				}.apply(a,[b])};

			l.onAdd=function(){
				if(!this.A){
				this.A=d;
				q(this)}};

			l.draw=function(){};

			function n(a){
				if(!a.j.length)for(var b=0,c;
				c=a.ca[b];
				b++)a.j.push({
					url:a.X+(b+1)+"."+a.W,height:c,width:c
				})
			}
			
			l.S=function(){
				for(var a=this.o(),b=new google.maps.LatLngBounds,c=0,e;e=a[c];c++)b.extend(e.getPosition());
				this.b.fitBounds(b)};
				l.z=k("j");
				l.o=k("a");
				l.V=function(){return this.a.length};

				l.I=function(){return this.Y||this.b.mapTypes[this.b.getMapTypeId()].maxZoom};

				l.G=function(a,b){
					for(var c=0,e=a.length,g=e;g!==0;){
						g=parseInt(g/10,10);
						c++
					}
					c=Math.min(c,b);
					return{text:e,index:c}
				};

				l.aa=j("G");
				l.H=k("G");
				l.C=function(a,b){
					for(var c=0,e;e=a[c];c++)t(this,e);
					b||this.i()
				};

				function t(a,b){
					b.s=i;
					b.draggable&&google.maps.event.addListener(b,"dragend",function(){
						b.s=i;
						a.K()
					});
					a.a.push(b)}l.q=function(a,b){
						t(this,a);
						b||this.i()
					};

				function u(a,b){
					var c=-1;
					if(a.a.indexOf)c=a.a.indexOf(b);
					else for(var e=0,g;g=a.a[e];e++)if(g==b){c=e;break}if(c==-1)return i;
					a.a.splice(c,1);
					return d
				}
				
				l.Z=function(a,b){
					var c=u(this,a);
					if(!b&&c){
						this.m();
						this.i();
						return d
					}else return i
				};

				l.$=function(a,b){
					for(var c=i,e=0,g;g=a[e];e++){g=u(this,g);c=c||g}if(!b&&c){this.m();this.i();return d}
				};

				l.U=function(){return this.f.length};

				l.getMap=k("b");
				l.setMap=j("b");
				l.w=k("g");
				l.ba=j("g");

				l.v=function(a){
					var b=this.getProjection(),c=new google.maps.LatLng(a.getNorthEast().lat(),a.getNorthEast().lng()),e=new google.maps.LatLng(a.getSouthWest().lat(),a.getSouthWest().lng());
					c=b.fromLatLngToDivPixel(c);
					c.x+=this.g;
					c.y-=this.g;
					e=b.fromLatLngToDivPixel(e);
					e.x-=this.g;
					e.y+=this.g;
					c=b.fromDivPixelToLatLng(c);
					b=b.fromDivPixelToLatLng(e);
					a.extend(c);
					a.extend(b);
					return a};

				l.R=function(){
					this.m(d);
					this.a=[]};

				l.m=function(a){
					for(var b=0,c;
					c=this.f[b];
					b++)c.remove();
					for(b=0;
					c=this.a[b];
					b++){
					c.s=i;
					a&&c.setMap(f)}this.f=[]};

				l.K=function(){
					var a=this.f.slice();
					this.f.length=0;
					this.m();
					this.i();
					window.setTimeout(function(){
					for(var b=0,c;
					c=a[b];
					b++)c.remove()},0)};

				l.i=function(){q(this)};

				function q(a){
					if(a.A)for(var b=a.v(new google.maps.LatLngBounds(a.b.getBounds().getSouthWest(),a.b.getBounds().getNorthEast())),c=0,e;
					e=a.a[c];
					c++)if(!e.s&&b.contains(e.getPosition())){
					var g=a;
					e=e;
					for(var o=4E4,r=f,x=0,p=void 0;
					p=g.f[x];
					x++){
					var h=p.getCenter();
					if(h){
					h=h;
					var s=e.getPosition();
					if(!h||!s)h=0;
					else{
					var y=(s.lat()-h.lat())*Math.PI/180,z=(s.lng()-h.lng())*Math.PI/180;
					h=Math.sin(y/2)*Math.sin(y/2)+Math.cos(h.lat()*Math.PI/180)*Math.cos(s.lat()*Math.PI/180)*Math.sin(z/2)*Math.sin(z/2);
					h=
					6371*2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h))}if(h<o){
					o=h;
					r=p}}}if(r&&r.F.contains(e.getPosition()))r.q(e);
					else{
					p=new v(g);
					p.q(e);
					g.f.push(p)}}}

				function v(a){
					this.k=a;
					this.b=a.getMap();
					this.g=a.w();
					this.l=a.l;
					this.r=a.r;
					this.d=f;
					this.a=[];
					this.F=f;
					this.n=new w(this,a.z(),a.w())}
				
				l=v.prototype;

				l.q=function(a){
					var b;
					a:if(this.a.indexOf)b=this.a.indexOf(a)!=-1;
					else{
					b=0;
					for(var c;
					c=this.a[b];
					b++)if(c==a){
					b=d;
					break a}b=i}if(b)return i;
					if(this.d){
					if(this.r){
					c=this.a.length+1;
					b=(this.d.lat()*(c-1)+a.getPosition().lat())/c;
					c=(this.d.lng()*(c-1)+a.getPosition().lng())/c;
					this.d=new google.maps.LatLng(b,c);
					A(this)}}else{
					this.d=a.getPosition();
					A(this)}a.s=d;
					this.a.push(a);
					b=this.a.length;
					b<this.l&&a.getMap()!=this.b&&a.setMap(this.b);
					if(b==this.l)for(c=0;
					c<b;
					c++)this.a[c].setMap(f);
					b>=this.l&&a.setMap(f);
					
					if(this.b.getZoom()>this.k.I())for(a=0;
					b=this.a[a];
					a++)b.setMap(this.b);
					else if(this.a.length<this.l)B(this.n);
					else{
					b=this.k.H()(this.a,this.k.z().length);
					this.n.setCenter(this.d);
					a=this.n;
					a.B=b;
					a.fa=b.text;
					a.da=b.index;
					if(a.c)a.c.innerHTML=b.text;
					b=Math.max(0,a.B.index-1);
					b=Math.min(a.j.length-1,b);
					b=a.j[b];
					a.N=b.url;
					a.h=b.height;
					a.p=b.width;
					a.L=b.textColor;
					a.e=b.anchor;
					a.M=b.textSize;
					a.D=b.backgroundPosition;
					this.n.show()}return d};

				l.getBounds=function(){
					for(var a=new google.maps.LatLngBounds(this.d,this.d),b=this.o(),c=0,e;
					e=b[c];
					c++)a.extend(e.getPosition());
					return a};

				l.remove=function(){
					this.n.remove();
					this.a.length=0;
					delete this.a};

				l.T=function(){
					return this.a.length};

				l.o=k("a");
				l.getCenter=k("d");

				function A(a){
					a.F=a.k.v(new google.maps.LatLngBounds(a.d,a.d))}
				
				l.getMap=k("b");

				function w(a,b,c){
					a.k.extend(w,google.maps.OverlayView);
					this.j=b;
					this.ea=c||0;
					this.u=a;
					this.d=f;
					this.b=a.getMap();
					this.B=this.c=f;
					this.t=i;
					this.setMap(this.b)}
				
				l=w.prototype;

				l.onAdd=function(){
					this.c=document.createElement("DIV");
					if(this.t){
					this.c.style.cssText=C(this,D(this,this.d));
					this.c.innerHTML=this.B.text}this.getPanes().overlayMouseTarget.appendChild(this.c);
					var a=this;
					this.c.id = ti;
					
					google.maps.event.addDomListener(this.c,"dblclick",function(){
					var b=a.u.k;
					google.maps.event.trigger(b,"clusterclick",a.u);
					b.O&&a.b.fitBounds(a.u.getBounds())});
					google.maps.event.addDomListener(this.c,"click",function(){

						ab = new InfoBox({
							disableAutoPan: false,
							maxWidth: 0,
							pixelOffset: new google.maps.Size(-40, -175),
							zIndex: null,
					
							boxStyle: { 
								background: "transparent",
								width: "260px",
								height: "155px",
							},
					
							closeBoxMargin: "10px 2px 2px 2px",
							closeBoxURL: "",
							infoBoxClearance: new google.maps.Size(1, 1),
							isHidden: false,
							pane: "floatPane",
							enableEventPropagation: false
						});

						ab.close(map);

						var htmlCont = '<div class="mapBubbleList bigger"><div class="innerList">';
						for(it = 0; it < mc.f[this.id].a.length; it++){
							htmlCont += '<div class="admap">'+
								'<a class="bubble" href="'+mc.f[this.id].a[it].lnk+'">'+
									'<img src="'+mc.f[this.id].a[it].img+'" alt=""/>'+ //Immagini
									'<p>'+
										'<span class="title">'+mc.f[this.id].a[it].title+'</span>'+
										'<span class="desc">'+mc.f[this.id].a[it].categoria+'</span>'+
										'<span class="price">Prezzo: <strong>'+mc.f[this.id].a[it].prezzo+'</strong></span>'+
									'</p>'+
								'</a>'+
							'</div>';
						}
						
						htmlCont += '</div></div>';
						scoller = false;
					    		
						ab.setOptions({
							latlng: mc.f[this.id].a[0].position,
							content: htmlCont
						});
							    		
			    		ab.open(map, mc.f[this.id].a[0]);
						if(ib) ib.close(map);
					
					})
					
					ti++;
				};

				function D(a,b){
					var c=a.getProjection().fromLatLngToDivPixel(b);
					c.x-=parseInt(a.p/2,10);
					c.y-=parseInt(a.h/2,10);
					return c}

				l.draw=function(){
					if(this.t){
					var a=D(this,this.d);
					this.c.style.top=a.y+"px";
					this.c.style.left=a.x+"px"}};

				function B(a){
					if(a.c)a.c.style.display="none";
					a.t=i}

				l.show=function(){
					if(this.c){
					this.c.style.cssText=C(this,D(this,this.d));
					this.c.style.display=""}this.t=d};

				l.remove=function(){
					this.setMap(f)};

				l.onRemove=function(){
					if(this.c&&this.c.parentNode){
					B(this);
					this.c.parentNode.removeChild(this.c);
					this.c=f}};

				l.setCenter=j("d");

				function C(a,b){
					var c=[];
					if(document.all)c.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="'+a.N+'");');
					else{c.push("background-image:url("+a.N+");");
					c.push("background-position:"+(a.D?a.D:"0 0")+";")}if(typeof a.e==="object"){
					typeof a.e[0]==="number"&&a.e[0]>0&&a.e[0]<a.h?c.push("height:"+(a.h-a.e[0])+"px;padding-top:"+a.e[0]+"px;"):c.push("height:"+a.h+"px;line-height:"+a.h+"px;");
					typeof a.e[1]==="number"&&a.e[1]>0&&a.e[1]<a.p?c.push("width:"+(a.p-a.e[1])+"px;padding-left:"+a.e[1]+"px;"):c.push("width:"+a.p+"px;text-align:center;")}else c.push("height:"+a.h+"px;line-height:"+a.h+"px;width:"+a.p+"px;text-align:center;");
					c.push("cursor:pointer;top:"+b.y+"px;left:"+b.x+"px;color:"+(a.L?a.L:"white")+";position:absolute;font-size:"+(a.M?a.M:11)+"px;font-family:Arial,sans-serif;font-weight:bold");
					return c.join("")}

window.MarkerClusterer=m;
m.prototype.addMarker=m.prototype.q;
m.prototype.addMarkers=m.prototype.C;
m.prototype.clearMarkers=m.prototype.R;

m.prototype.fitMapToMarkers=m.prototype.S;
m.prototype.getCalculator=m.prototype.H;
m.prototype.getGridSize=m.prototype.w;
m.prototype.getExtendedBounds=m.prototype.v;
m.prototype.getMap=m.prototype.getMap;
m.prototype.getMarkers=m.prototype.o;
m.prototype.getMaxZoom=m.prototype.I;
m.prototype.getStyles=m.prototype.z;
m.prototype.getTotalClusters=m.prototype.U;
m.prototype.getTotalMarkers=m.prototype.V;
m.prototype.redraw=m.prototype.i;
m.prototype.removeMarker=m.prototype.Z;
m.prototype.removeMarkers=m.prototype.$;

m.prototype.resetViewport=m.prototype.m;
m.prototype.repaint=m.prototype.K;
m.prototype.setCalculator=m.prototype.aa;
m.prototype.setGridSize=m.prototype.ba;
m.prototype.onAdd=m.prototype.onAdd;
m.prototype.draw=m.prototype.draw;
v.prototype.getCenter=v.prototype.getCenter;
v.prototype.getSize=v.prototype.T;
v.prototype.getMarkers=v.prototype.o;
w.prototype.onAdd=w.prototype.onAdd;
w.prototype.draw=w.prototype.draw;
w.prototype.onRemove=w.prototype.onRemove;

})();


