// JavaScript Document
var GeneralFunction = function(){
	var GF = {
		iDebug: 0,
		ShowOverlay: function(){
			var o=$('Overlay');
			o.style.height = $('Site').offsetHeight+"px";
			var MaxAlpha = 80;
			if(!o.Visible){
				o.Visible=true;
				NS_ieFix().selShow(false,"RichiestaInfo_form");
				NS_fade(o,0,MaxAlpha,0.2,null);
			}else{
				o.Visible=false;
				NS_ieFix().selShow(true,"RichiestaInfo_form");
				NS_fade(o,MaxAlpha,0,0.2,null);	
			}
		},
		height_zone_geo_box: null,
		ShowZonegeo: function(show){
			var o=$('zone_geo_box');
			var Hmin=65;
			if(show){
				o.NS_openLayerVars=null;//resetta la variabile
				$('zone_geo_showall').style.display = "none";
				$('zone_geo_hiddenall').style.display = "block";
			}else{
				if(this.height_zone_geo_box==null){
					this.height_zone_geo_box = o.offsetHeight;
				}
				o.style.overflow="hidden";
				$('zone_geo_showall').style.display = "block";
				$('zone_geo_hiddenall').style.display = "none";
			}
			if(typeof(o.NS_openLayerVars)=='undefined'){
				var h = this.height_zone_geo_box;
				o.NS_openLayerVars={
					aperto:true,inApertura:false,minW:"auto",minH:Hmin,maxW:"auto",maxH:h,w:"auto",h:h,idTime:null,DIVISORE_VEL:3,MS:25
				};
			}
			NS_openLayer(o,"auto","auto",Hmin,this.height_zone_geo_box,false);
		},
		
		height_SubRicerca: null,
		ShowComuniList: function(){
			var o=$('SubRicerca_elencoComuni');
			var Hmin = arguments[0]>0 ? arguments[0] : 0;
			if(o.offsetHeight==0){ //apertura
				o.NS_openLayerVars=null;//resetta la variabile
			}else{ //chiusura
				if(this.height_SubRicerca==null){
					this.height_SubRicerca = o.offsetHeight;
				}
				o.style.overflow="hidden";
			}
			
			if(typeof(o.NS_openLayerVars)=='undefined'){
				var h = this.height_SubRicerca;
				o.NS_openLayerVars={
					aperto:true,inApertura:false,minW:"auto",minH:Hmin,maxW:"auto",maxH:h,w:"auto",h:h,idTime:null,DIVISORE_VEL:3,MS:25
				};
			}
			NS_openLayer(o,"auto","auto",Hmin,this.height_SubRicerca,false);
		},
		
		showMenu:function(obj_id,MaxAlpha){
			o = $(obj_id);
			if(!o.Active){
				o.Active=true;
				NS_fade(o,0,MaxAlpha,0.3,null);
				
				o.Hide = function(MaxAlpha){
					if(GF.iDebug<-5){
						alert(this.id+" "+this.Active);
						GF.iDebug++;
					}
					clearTimeout(this.idTime);
					if(!this.Active){
						NS_fade(this,MaxAlpha,0,0.3,null);
					}else{
						var o=this;
						this.idTime = setTimeout("o.Hide("+MaxAlpha+")",1000);
					}
				};
				o.idTime = setTimeout("o.Hide("+MaxAlpha+")",1000);
				//setInterval("o.Hide("+MaxAlpha+")",1000);
			}
		}
	};
	return GF;
}
var GF = new GeneralFunction();

var EventiBox = function(){
	var EventiBox = {
		id: new Array(),
		idTime: null,
		indice: -1,
		iActive: 0,
		play: false,
		secondi: 3,
		add: function(id){
			var x = this.id.length;
			this.id[x] = id;
		},
		Init: function(secondi){
			this.secondi=secondi;
			this.Play();
		},
		Play: function(){
			this.play = true;
			this.StartEB();
		},
		StartEB: function(){
			if(this.idTime>0)
				clearTimeout(this.idTime);
			if(this.play){
				var n = this.id.length;
				this.indice = this.indice==n-1 ? 0 : this.indice+1;
				this.setDiv(this.indice);
				this.idTime = setTimeout("EB.StartEB()",this.secondi*1000);
			}
		},
		Pause: function(){
			this.play = false;
			clearTimeout(this.idTime);
		},
		setDiv: function(i){
			$('EventoScheda'+this.id[this.iActive]).style.display = "none";
			$('EventoScheda'+this.id[i]).style.display = "block";
			this.iActive=i;
		},
		DetailBoxEventi: function(id,show){
			var alphaMax = 80;
			if(show){
				NS_fade("DetailBoxEventi"+id,0,alphaMax,0.2,null);
			}else{
				NS_fade("DetailBoxEventi"+id,alphaMax,0,0.2,null);
			}
		}
	};
	return EventiBox;
}