// La larghezza della div con lo zoom
var larghezzaDiv = 500;
// La larghezza dello schermo
var larghezzaSchermo; 
// Intervallo in millisecondi per l'effetto fade
var intervalloFade = 100
// Trasparenza iniziale della div
var divOpacity = 20
// Step di incremento della trasparenza
var incrementoOpacity = 5


function high(which2) {
	theobject=which2
	highlighting=setInterval("highlightit(theobject)",intervalloFade)
}

function low(which2) {
	clearInterval(highlighting)
	which2.filters.alpha.opacity=divOpacity //deve essere uguale al valore in #immaginePopup del css
}

function highlightit(cur2) {
	if (cur2.filters.alpha.opacity<100)
		cur2.filters.alpha.opacity+=incrementoOpacity
	else if (window.highlighting)
	clearInterval(highlighting)
}

function impostaPosizione(){
	if (window.innerWidth){ 
		larghezzaSchermo = window.innerWidth; 
	} 
	if (document.body.clientWidth){ 
		larghezzaSchermo = document.body.clientWidth; 
	}
	if	(document.all)//IE
	{
		document.all.divImmaginePopup.style.left =  (larghezzaSchermo-larghezzaDiv)/2 + 'px';
		
	}
	else if (document.getElementById)//NS
	{
		temp = document.getElementById('divImmaginePopup');
		temp.style.left =  (larghezzaSchermo-larghezzaDiv)/2 + 'px';
	}
}

function mostraImmagine(immagine) {
	if (immagine == "")
	{
	//	alert(immagine)
		immagine = "noimage.gif";
	//	alert(immagine)
	}
	if	(document.all)//IE
	{
		document.all.immaginePopup.src = '../writable/' + immagine;	
		document.all.divImmaginePopup.style.visibility = 'visible';
		
	}
	else if (document.getElementById)//NS
	{
		temp1 = document.getElementById('immaginePopup');
		temp1.src = '../writable/' + immagine;
		temp1 = "";
		
		temp2 = document.getElementById('divImmaginePopup');
		temp2.style.visibility = 'visible';
		temp2 = "";
	}
}

function openPopup(immagine){
	try
	{
		high(immaginePopup);
		chiudiPopup();
	}
	catch(er){}
	
	impostaPosizione();
	mostraImmagine(immagine);
	JSFX_FloatTopDiv();
	
	try
	{
		high(immaginePopup);
	}
	catch(er){}
}
function chiudiPopup(){
	if	(document.all)//IE
	{
		try
		{
			low(immaginePopup);
		}
		catch(er){}
		
		document.all.divImmaginePopup.style.visibility = 'hidden';
	}
	else if (document.getElementById)//NS
	{
		temp = document.getElementById('divImmaginePopup');
		temp.style.visibility = 'hidden';
		temp = "";
	}
}
function openPopup2(titolo,immagine,testo){
	try
	{
		high(immaginePopup);
		chiudiPopup();
	}
	catch(er){}
	
	impostaPosizione();
	mostraTitolo(titolo);
	mostraImmagine(immagine);
	mostraTesto(testo);
	JSFX_FloatTopDiv();
	
	try
	{
		high(immaginePopup);
	}
	catch(er){}
}
//
window.onresize = function() {
	impostaPosizione();
}

function mostraTitolo(titolo)
{
	if	(document.all)//IE
	{
		document.all.titolopopup.innerHTML = titolo;
		//document.all.divImmaginePopup.style.visibility = 'visible';
		
	}
	else if (document.getElementById)//NS
	{
		temp1 = document.getElementById('titolopopup');
		temp1.innerHTML = titolo;
		temp1 = "";
	}
	
}
function mostraTesto(testo)
{
	if	(document.all)//IE
	{
		document.all.testopopup.innerHTML = testo;
		//document.all.divImmaginePopup.style.visibility = 'visible';
		
	}
	else if (document.getElementById)//NS
	{
		temp1 = document.getElementById('testopopup');
		temp1.innerHTML = testo;
		temp1 = "";
	}
	
}

function JSFX_FloatTopDiv()
{
	var startX = 300,
	startY = 100;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x;this.style.top=y;};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function()
	{
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : document.body.scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("divImmaginePopup");
	stayTopLeft();
}
var verticalpos="fromtop"