var quanImg;
var Nimg;

function show(NUMIMG)
{
nImg=NUMIMG;
/* ------ sfondo trasparente ----------- */
sfondoTrasp=document.createElement("DIV");
sfondoTrasp.style.position="absolute";
sfondoTrasp.style.top=0;
sfondoTrasp.style.left=0;
sfondoTrasp.style.width="100%";
sfondoTrasp.style.height="100%";
sfondoTrasp.style.background="black";
sfondoTrasp.style.filter="alpha(opacity:60)";
sfondoTrasp.style.opacity=0.6;
sfondoTrasp.style.zIndex=10;
document.body.appendChild(sfondoTrasp);
/* ------conice bianca della foto ------ */
sfondoFoto=document.createElement("DIV");
sfondoFoto.style.position="absolute";
sfondoFoto.style.top=15+"%";
sfondoFoto.style.left=20+"%";
sfondoFoto.style.width="65%";
sfondoFoto.style.height="80%";
sfondoFoto.style.background="white";
sfondoFoto.style.zIndex=11;
sfondoFoto.setAttribute("align","right");
/* -----tasto chiudi ------------------*/
contChiudi=document.createElement("A");
contChiudi.setAttribute("HREF","#");
chiudi=document.createTextNode("Chiudi X ");
contChiudi.appendChild(chiudi);
contChiudi.style.cursor="pointer";
contChiudi.onclick=ritorna;
contChiudi.style.zIndex=12;
sfondoFoto.appendChild(contChiudi);
/* ----------- frecce laterali --------------*/
/*--destra---*/
destra= document.createElement("DIV"); 
destra.style.position ="absolute";
destra.style.width=10+"%";
destra.style.height="90%";
destra.style.top="10%";
destra.style.left="90%";
destra.style.backgroundColor="white";
destra.style.zIndex=14;
destra.onmouseover=visdestra;
destra.onmouseout=unvisdestra;
sfondoFoto.appendChild(destra);
fDestra=document.createElement("IMG"); 
fDestra.src="../gif/right.jpg";
fDestra.style.position ="absolute";
fDestra.style.bottom="45%";
fDestra.style.left="0%";
fDestra.style.cursor="pointer";
destra.appendChild(fDestra);
/*--sinistra--*/
sinistra= document.createElement("DIV"); 
sinistra.style.position ="absolute";
sinistra.style.width=10+"%";
sinistra.style.height="90%";
sinistra.style.top="10%";
sinistra.style.left="0%";
sinistra.style.backgroundColor="white";
sinistra.style.zIndex=14;
sinistra.onmouseover=vissinistra;
sinistra.onmouseout=unvissinistra;
sfondoFoto.appendChild(sinistra);
fsinistra=document.createElement("IMG"); 
fsinistra.src="../gif/left.jpg";
fsinistra.style.position ="absolute";
fsinistra.style.bottom="45%";
fsinistra.style.left="0%";
fsinistra.style.cursor="pointer";

sinistra.appendChild(fsinistra);
/* ---------------------------------------*/
caricaimg();
document.body.appendChild(sfondoFoto);
contInt=1;
Intermit();

fDestra.onclick=succ;
fsinistra.onclick=prec;
}

function Intermit() 
{
contInt++;
if (contInt < 9){
	if ( (contInt%2)==0 )	{unvisdestra();unvissinistra();}
    	else	{visdestra() ;vissinistra() ;}
	
	setTimeout("Intermit()",100);
	}
else  return;
}

function caricaimg()
{
if (nImg < 10) ind= "url("+"./foto/0"+nImg+".jpg"+")";
else  ind = "url("+"./foto/"+nImg+".jpg"+")";
sfondoFoto.style.backgroundImage=ind;
sfondoFoto.style.backgroundPosition ="center center";
sfondoFoto.style.backgroundRepeat ="no-repeat";
}

function succ()
{
if (nImg < quanImg) nImg +=1;
	else nImg =1;
caricaimg(nImg);
}

function prec()
{
if (nImg==1) nImg=quanImg;
	else nImg -=1;
caricaimg(nImg);
}

function unvisdestra()
{
destra.style.filter="alpha(opacity:0)";
destra.style.opacity=0.0;
}

function unvissinistra()
{
sinistra.style.filter="alpha(opacity:0)";
sinistra.style.opacity=0.0;
}

function visdestra() 
{
destra.style.filter="alpha(opacity:100)";
destra.style.opacity=1.0;
}

function vissinistra() 
{
sinistra.style.filter="alpha(opacity:100)";
sinistra.style.opacity=1.0;
}

function ritorna()
{
destra.removeChild(fDestra);
sinistra.removeChild(fsinistra);
sfondoFoto.removeChild(destra);
sfondoFoto.removeChild(sinistra);
sfondoFoto.removeChild(contChiudi);
document.body.removeChild(sfondoFoto);
document.body.removeChild(sfondoTrasp);
}

function inizio2(QUANTITA) 
{

	quanImg = QUANTITA;
	tabella = document.getElementById("tab");
	tabella.style.zIndex = 3;
        tabella.style.visibility="visible";
	y=0;
	caduta();
	
}

function caduta() 
{
var perc;
if(quanImg<=5) perc=40;
else if(quanImg<=10 && quanImg>5) perc=30;
else perc=25;
	if (y <= perc ){
	y += 0.5;
	tabella.style.top = y+"%" ;
	t=setTimeout("caduta()",5);
	}
	else  return ;
}
