
	// APRE LAYPOP IMMAGINI
		function display(num) {
			// metto la pop trasparente
			setOpacity('layer_pop', 0);
			// avvio il fade
			fadeIn();
			// aspetto un pochino e visualizzo il layer immagine
			window.setTimeout("draw_layer('"+num+"')", 100);
			
		}

	// CHIUDE LAYPOP IMMAGINI
		function hideLayers(){
			CloseGallery();
			fadeOut();
		}

	// FADE BACKGROUND TO BLACK
		function fadeIn() {
			delay=0;
			// nome del layer background
			objId = 'fadeBack'
			obj = document.getElementById(objId);
			// metto il layer completamente trasparente
			setOpacity(objId, 0);
			// accendo il layer
			obj.style.visibility = "visible";
			// scrollo il layer al top dello schermo visibile
			obj.style.top=document.body.scrollTop+0+"px";
			obj.style.height=document.body.clientHeight +500+ "px";
			obj.style.width=document.body.offsetWidth + "px";
			obj.style.overflow='hidden';
			document.body.style.overflow='hidden';
			// opacità iniziale
			opacity = 5;
			if (document.getElementById) {
				while (opacity <= 65) {
					//alert(opacity);
					window.setTimeout("setOpacity('"+objId+"',"+opacity+")", delay);
					opacity += 5;
					delay   += 10; // modify to change fade speed
				}
			}
		}

	// REMOVE BLACK BACKGROUND
		function fadeOut() {
			// nome del layer background
			objId = 'fadeBack'
			obj = document.getElementById(objId);
			obj.style.visibility="hidden";
			obj.style.top=document.body.scrollTop-10;
			obj.style.width='1px';
			obj.style.height='1px';
			document.body.style.overflow='scroll';
		}

	// APRE LAYER IMMAGINI
		function draw_layer(poza) {
			if (parseInt(poza)>=totimgs) poza =0
			if (parseInt(poza)<0) poza=totimgs-1
			currentPos=poza
			var layer = document.getElementById('layer_pop');
			//var cx = (document.body.offsetWidth-layer.style.pixelWidth)/2+document.body.scrollLeft;
			//var cy = (document.body.offsetHeight-layer.style.pixelHeight)/2+document.body.scrollTop-50;
			var width  = sizex[poza];
			var height = sizey[poza];
			
			opacity = 0;
			while (opacity <= 100) {
				//alert(opacity);
				window.setTimeout("setOpacity('layer_pop',"+opacity+")", delay);
				opacity += 1;
				delay   += 5; // modify to change fade speed
			}
			document.getElementById('poza_layer').src   = '/_img/x.gif';
			document.getElementById('poza_layer').src   = imgs[poza];
			document.getElementById('poza_layer').width = width;
			document.getElementById('poza_layer').height= height;
			var cx = (document.body.offsetWidth - width)/2+document.body.scrollLeft;
			var cy;
			if (typeof window.pageYOffset != 'undefined') {
			   cy = window.pageYOffset;
			}
			else if (typeof document.compatMode != 'undefined' &&
				 document.compatMode != 'BackCompat') {
			   cy = document.documentElement.scrollTop;
			}
			else if (typeof document.body != 'undefined') {
			   cy = document.body.scrollTop;
			}
			cy += 20;
			document.getElementById('layer_pop').style.top = cy + "px";
			document.getElementById('layer_pop').style.left = cx + "px";
			document.getElementById('layer_pop').style.visibility = 'visible';
			document.getElementById('layer_pop').style.width = parseInt(width) + "px";
		}
	
	// CHIUDE LAYER IMMAGINI
		function CloseGallery() {
			document.getElementById('layer_pop').style.visibility='hidden';
			//document.getElementById('layer_pop').style.pixelWidth=358
			//document.getElementById('layer_pop').style.pixelHeight=400
		}
		
	// FUNZIONE PER IL FADE DEGLI OGGETTI
		function setOpacity(objId, opacity) {
			if (document.getElementById) {
				obj = document.getElementById(objId);
				opacity = (opacity == 100)?99.999:opacity;
				// IE/Win
				obj.style.filter = "alpha(opacity:"+opacity+")";
				// Safari<1.2 Konqueror
				obj.style.KHTMLOpacity = opacity/100;
				// Older Mozilla and Firefox
				obj.style.MozOpacity = opacity/100;
				// Safari 1.2, newer Firefox and Mozilla, CSS3
				obj.style.opacity = opacity/100;
			}
		}
