<!-- //

function goflash(ogg) {
	document.write(ogg);
}

isvisib = new Array();

function agm_esegui () {
	CaricaImmagini();
}

function barraStato(vValore) {
	window.status=vValore;
	return true;
}


function naviBack() {
	parent.main.history.back();
	return true;
}

var finestraNuova;
function showFinestra(vFile,vTit,vScroll,vw,vh) {

	// La finestra non &egrave; scrollabile (contiene una foto)
	var vTesto,vw2,vh2,vWidth,vHeight;
	var vLeftRight='';
	var vTopBottom='';

	if(vw==0) 		vw2	= 640;	//larghezza se foto orizzontale
	else if(vw==-1) vw2	= 360;	//larghezza se foto verticale
	else if(vw==-2) {
		vw2	= screen.availWidth;
		vLeftRight='left=0,right=0,screenX=0,';
	}
	else if(vw==-3) {
		vw2	= 780;
		Left = screen.availWidth - vw2
		vLeftRight='left='+ Left +',right=0,screenX=0,';
	}
	else vw2 = vw;

	if(vh==0) 		vh2	= 480;	//altezza se foto orizzontale
	else if(vh==-1) vh2	= 480;	//altezza se foto verticale
	else if(vh==-2) {
		vh2	= screen.availHeight;
		vTopBottom='top=0,bottom=0,screenY=0,';
	}
	else if(vh==-3) {
		vh2	= screen.availHeight;
		vTopBottom='top=0,bottom=0,screenY=0,';
	}
	else vh2 = vh;

	if(vScroll == 'yes') {
		( vw == -2  || vw == -3 ) || ( vw2=vw2+40 );
		( vh == -2  || vh == -3 ) || ( vh2=vh2+65 );
	}
	else {
		vScroll='no';
		( vw == -2   || vw == -3 ) || ( vw2=vw2 + 35 );
		( vh == -2   || vh == -3 ) || ( vh2=vh2 + 85 );
	}
	vWidth	='width='	+ vw2 +',';
	vHeight	='height=' + vh2 +',';

//	alert('toolbar=no,location=no,directories=no,titlebar=no,status=yes,scrollbars='+vScroll+',resizable=yes,' + vWidth  + vHeight  + vLeftRight + vTopBottom +'menubar=no');
	finestraNuova && finestraNuova.close();
	finestraNuova = open(vFile,vTit,'toolbar=no,location=no,directories=no,titlebar=no,status=yes,scrollbars='+vScroll+',resizable=yes,' + vWidth  + vHeight  + vLeftRight + vTopBottom +'menubar=no');
	finestraNuova.resizeTo(vw2,vh2);
	finestraNuova.focus();
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
/* Functions that swaps images. */
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Functions that handle preload. */
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function MouseEnter(id,classe,vCursor) {
	obj = document.getElementById(id);
	obj.className = classe;
	if(vCursor) {
		vocemenu.style.cursor = vCursor;
	}
}

function MouseLeave(id,classe,vCursor) {
	obj = document.getElementById(id);
	if ( isvisib[id]==true ) {
		return false;
	}
	obj.className = classe;
	if(vCursor) {
		vocemenu.style.cursor = vCursor;
	}
	return true;
	
}

/*
function gestPulsanti(id,classe,vCursor){
	vocemenu = document.getElementById(id);
	if (sottomenu = document.getElementById('idsub_'+id) );
	if (isvisib[id]!=true) {
		isvisib[id]=true;
		vocemenu.className = classe+'_on';
		if(sottomenu) {
			sottomenu.style.display='block';
		}
	} else {
		isvisib[id]=false;
		vocemenu.className = classe;
		if(sottomenu) {
			sottomenu.style.display='none'; 
		}
	}
	if(vCursor) {
		vocemenu.style.cursor = vCursor;
	}
}
*/



function gestPulsanti(id,classe,vCursor) {
	vocemenu = document.getElementById(id);
	if(!vocemenu) return false;
//	if (sottomenu = document.getElementById('idsub_'+id) );
	if (isvisib[id]!=true) {
		isvisib[id]=true;
		vocemenu.className = classe+'_on';
	var i = 1;
	for(i=1; vocesottomenu = document.getElementById(id+i);i++) {
			if(!vocesottomenu) break;
			vocesottomenu.style.display='block';
		}
	} else {
		isvisib[id]=false;
		vocemenu.className = classe;
		for(i=1; vocesottomenu = document.getElementById(id+i);i++) {
			if(!vocesottomenu) break;
			vocesottomenu.style.display='none';
		}
	}
	if(vCursor) {
		vocemenu.style.cursor = vCursor;
	}
}





function Checked (id) {
	obj=document.getElementById(id);
	obj_nolink = document.getElementById(id+'_nolink');
	obj.style.display = 'none';
	obj_nolink.style.display = 'block';
}









function CL_CrossBrowser() {

	this.addEventListener = function (target,evt,listener,useCapture) {
		if(target.addEventListener) {
				target.addEventListener(evt,listener,useCapture);
				return;
		}
	
		if(target.attachEvent) {
			target.attachEvent('on' + evt, listener);
			return;
		}
	}


	this.opacity = function(obj,op) {
		if( op==100 && (obj.style.opacity!= undefined || obj.style.MozOpacity!=undefined) ) op=99;
		obj.style.opacity = op/100;
		obj.style.MozOpacity = op/100;
		obj.style.filter = 'alpha(opacity='+ op +')';
	}



	// set the page coordinates as the user scrolls down the page
	this.scrollTop = function(){
		var y=0;
		if(document.documentElement.scrollTop > 0 ) {
			y=document.documentElement.scrollTop;
		}
		else if(document.body.scrollTop > 0 ){
			y=document.body.scrollTop;
		}
		else if(window.pageYOffset > 0 ) {
			y=window.pageYOffset;
		}
		return y;
	}


	this.scrollLeft = function(){
		var x=0;
		if(document.documentElement.scrollLeft > 0 ) {
			x=document.documentElement.scrollLeft;
		}
		else if(document.body.scrollLeft > 0 ){
			x=document.body.scrollLeft;
		}
		else if(window.pageXOffset > 0 ) {
			x=window.pageXOffset;
		}
		return x;
	}




//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
// Edit for CL_CrossBrowser (this class)
//	function getPageSize(){
	this.getPageSize = function() {

		var xScroll, yScroll
		var yCorrettore = 20;
	
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight + yCorrettore;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
	
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
	
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}

		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}

		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	}





	this.scrollHeight = function(obj) {
		var h = -1;
		if(obj===document.body) {
			if( obj = document.documentElement) {
				h = obj.scrollHeight + 'px';
			}
			else {
				obj = document.body;
				obj.style.height = 'auto';
				h = obj.scrollHeight + 'px';
				obj.style.height = '100%';
			}
		}
		else {
				h = obj.scrollHeight + 'px';
		}
	
		return h;
	}

	this.scrollWidth = function(obj) {
		var h = -1;
		if(obj===document.body) {
			(obj = document.documentElement) || (obj = document.body);
		}
		h = obj.scrollWidth + 'px';
		return h;
	}

}



/* Esistono delle differenze tra il modello proposto dal W3C
(e seguito da Netscape e Mozilla) e quello adottato da Explorer.
Le diversità si rifletteranno anche sulle informazioni che
l'oggetto Event può fornire nei diversi browser.
Opera sembra essere un ibrido in quanto supporta molte delle proprietà
definite sia dal W3C sia da Explorer. 

In linea di principio viene verificata l'adesione agli standard del W3C

(da parte di Internet Explorer)
 */
function CL_Event(evt) {

	var oSelf = this;
	if(!evt) evt=window.event;
	this.target = evt.target||evt.srcElement;

	// proprietà relatedTarget
	relatedTgt();

	// Posizione del mouse rispetto all'elemento che ha attivato l'evento
	this.offsetX = evt.offsetX ? evt.offsetX : evt.layerX;
	this.offsetY = evt.offsetY ? evt.offsetY : evt.layerY;

	// Interrompe il flusso dell'evento
	this.stopPropagation = function () {
		//supportato da Opera 5+
		if(evt.stopPropagation) evt.stopPropagation();
		else evt.cancelBubble=true;
	}

	// Elimina l'azione predefinita dell'evento
	this.preventDefault = function () {
		if(evt.preventDefault) evt.preventDefault();
		else evt.returnValue=true;
	}


	/* EVENTI LEGATI ALL'USO DEL MOUSE */

	function relatedTgt() {
		var mw3 = (evt.relatedTarget && evt.target) ? 1 : 0;
		// mw3 permette di stabilire se il
		// browser supporta le proprietà standard
		// che interessano gli eventi di mouseover e mouseout
//		oSelf.fromElement	= (mw3)	? ( (evt.type=="mouseover")	 ? 	evt.relatedTarget :evt.target )	: evt.fromElement;
//		osSlf.toElement		= (mw3)	? ( (evt.type=="mouseout")	 ?	evt.relatedTarget :evt.target )	: evt.toElement;
		if(evt.type=='mouseover') {
			oSelf.relatedTarget	= 	mw3	?	evt.relatedTarget	: evt.fromElement;
		}
		else if(evt.type=='mouseout') {
			oSelf.relatedTarget	= 	mw3	?	evt.relatedTarget	: evt.toElement;
		}


	}

}





function CL_ImgPopup() {

	var oSelf = this;
	var cross;
	var imgs = [];
	var yesMouseEvents = true;

	init();
	function init() {
		cross = new CL_CrossBrowser();
		cross.addEventListener(window,'load',windowListener,false);
	}


	function windowListener() {
		var espressione = /.+\.(jpe?g|gif|png)$/i;
		var links = document.getElementsByTagName('a');
		if(links) {
			for(i=0;i<links.length;i++) {
				var obj = links[i];
				if( espressione.test(obj.href) ) {
					cross.addEventListener(obj,'click',OpenPopup, false);
					obj.onclick =	function() {
											return false;
									}
					cross.addEventListener(obj,'mouseover',mouseoverListener,false);
					cross.addEventListener(obj,'mouseout',mouseoutListener,false);

					if(obj.firstChild && obj.firstChild.nodeName=='IMG') {
						var thObj = obj.firstChild;
						
						obj.className = obj.className ? ' + popup_thumb' : 'popup_thumb';
						imgs.push(thObj);
						cross.opacity(thObj,0);
						thFadeInit(thObj);
					}
				}
			}
		}
	}

	function thFadeInit(thObj) {
		if(thObj.complete==false) {
			clearTimeout(thObj.idTimer);
			thObj.idTimer = setTimeout(function(){ thFadeInit(thObj) },50);
			return;
		}
		clearTimeout(thObj.idTimer);
		thObj.cont = 0;
		thFade(thObj);
		thObj.thOpacity = 100;
		thObj.idTimer2 = [];
	}

	
	function thFade(thObj) {
		if(thObj.cont < 100) {
			cross.opacity(thObj,thObj.cont += 15);
			clearTimeout(thObj.idTimer);
			setTimeout(function(){ thFade(thObj) },50)
			return;
		}
		cross.opacity(thObj,100);
		clearInterval(thObj.idTimer);
		thObj.idTimer = null;
		thObj.cont = null;
	}

	function mouseoverListener(evt) {
		var e = new CL_Event(evt);
		var target = e.target;
		mouseoverFade(target);
	}
	var opMin = 75;
	function mouseoverFade(obj) {

		if(obj.nodeName != 'IMG') return;
		if(obj.idTimer != null) return;
		if(yesMouseEvents == false) return;

		var idTimer2 = obj.idTimer2;
		var delay = 50;
		var step = 5;
		if(obj.thOpacity > opMin) {
			for(i=0;i<idTimer2.length;i++) {
				clearTimeout( idTimer2.pop() );
			}
			if( (obj.thOpacity -= step) < opMin ) obj.thOpacity = opMin;
			cross.opacity(obj, obj.thOpacity);
			idTimer2.push( setTimeout(function(){mouseoverFade(obj)},delay) );
		}
		else {
			for(i=0;i<idTimer2.length;i++) {
				clearTimeout( idTimer2.pop() );
			}
			cross.opacity(obj, obj.thOpacity = opMin);
			obj.idTimer2 = [];
		}
	}

	
	function mouseoutListener(evt) {
		var e = new CL_Event(evt);
		var target = e.target;
		mouseoutFade(target);
	}
	var opMax = 100;
	function mouseoutFade(obj) {

		if(obj.nodeName != 'IMG') return;
		if(obj.idTimer != null) return;
		if(yesMouseEvents == false) return;

		var idTimer2 = obj.idTimer2;
		var delay = 50;
		var step = 5;
		if(obj.thOpacity < opMax) {
			for(i=0;i<idTimer2.length;i++) {
				clearTimeout( idTimer2.pop() );
			}
			if( (obj.thOpacity += step) > opMax ) obj.thOpacity = opMax;
			cross.opacity(obj, obj.thOpacity);
			idTimer2.push( setTimeout(function(){mouseoutFade(obj)},delay) );
		}
		else {
			for(i=0;i<idTimer2.length;i++) {
				clearTimeout( idTimer2.pop() );
			}
			cross.opacity(obj, obj.thOpacity = opMax);
		}
	}
	

	var coprente;
	var div_immagine;
	var immagine;
	var div_slider;
	var yesPopupFadeIn = true;
	function OpenPopup(evt) {
		yesPopupFadeIn = true;
		var e = new CL_Event(evt);
		var target = e.target;
		var targetIsImg = (target.nodeName == 'IMG');
		var objListener = ( targetIsImg ? target.parentNode : target );
		if(targetIsImg) target.thOpacity = opMax;
		coprente = document.createElement('div');
		coprente.setAttribute("id","popup_coprente");

		coprente.style.height = cross.getPageSize()[1] + 'px';	//cross.scrollHeight(document.body);
		coprente.style.top = 0;
		cross.opacity(coprente,70);
		coprente.onclick = ClosePopup;
		yesMouseEvents = false;
		var i;
		for(i=0; i < imgs.length; i++) {
			var idTimer2;
			while( (idTimer2 = imgs[i].idTimer2.pop()) != undefined ) {
				clearTimeout(idTimer2);
			}
			cross.opacity(imgs[i],100);
		}



		document.body.appendChild(coprente);

		div_immagine = document.createElement('div');
		div_immagine.setAttribute("id","popup_div_immagine");
		div_immagine.onclick = ClosePopup;
		document.body.appendChild(div_immagine);

		divPopupLoading = document.createElement('div');
		divPopupLoading.setAttribute('id','divPopupLoading');


//		var avviso = document.createTextNode('...caricamento immagine');
//		div_slider.appendChild(avviso);
		document.body.appendChild(divPopupLoading);
		divPopupLoading.style.top= 100 + cross.scrollTop() + 'px';


		immagine = document.createElement('img');
		immagine.setAttribute('src',objListener.href);

		immagine.onclick = ClosePopup;
		immagine.setAttribute('id','popup_immagine');
		if(targetIsImg) {
			immagine.alt = target.alt ? target.alt : target.title;
		}
		else {
			immagine.alt = objListener.title;
		}
		var pattern = / *([*-] +)?fai *clic(k?) *per *ingrandire( +[*-] *)?/i;
		immagine.alt = immagine.alt.replace(pattern,'');
		pattern = / *([*-] +)?click *to *enlarge( +[*-] *)?/i;
		immagine.alt = immagine.alt.replace(pattern,'');
		immagine.title = immagine.alt;

		crono();

		return false;
	}

	var timer = null;
	function crono() {
		timer && clearTimeout(timer);
		if(yesPopupFadeIn == false) return;
		if ( immagine.complete == false ) {
			timer = setTimeout(crono,50);
			return;
		}
		div_immagine.appendChild(immagine);
		divPopupLoading.className ='PopupLoadingStop';
		fadeInInit();
	}

	var i;
	var op1;
	var fat;
	function fadeInInit() {
		if(yesPopupFadeIn == false) return;
		i = 0;
		op1 = 100;
		fat = 15;
		div_immagine.style.top = 50 + cross.scrollTop() + 'px';
		cross.opacity(immagine,i);
		timer = setTimeout(fadeIn,50);
	}


	function fadeIn() {
		i = i + fat;
		timer && clearTimeout(timer);
		if(yesPopupFadeIn == false) return;
		if(i>op1) {
			i=op1;
			cross.opacity(immagine,i);
			var obj = document.getElementById('divPopupLoading');
			if(obj) document.body.removeChild(obj);
			return;
		}
		cross.opacity(immagine,i);
		timer = setTimeout(fadeIn,50);
	}
	

	function ClosePopup() {
		var obj, obj2;
		yesMouseEvents = true;
		yesPopupFadeIn = false;
		timer && clearTimeout(timer);
		timer = null;
		if(obj = document.getElementById('popup_coprente') ) document.body.removeChild(obj);
		if( obj2 = document.getElementById('popup_div_immagine') ) {
			if(obj = document.getElementById('popup_immagine') ) {
				obj2.removeChild(obj);
			}
			document.body.removeChild(obj2);
		}
		if( obj = document.getElementById('divPopupLoading') ) document.body.removeChild(obj);
	}
}

ocl_imgPopup = new CL_ImgPopup();




//-->	
