// Background slide

var imageArray = new Array();

// Velocità slide.
var ms = 3000;

// id del div

var divID = "corpo_left";

var wait = 0;

// Array delle immagini, se devi aggiungere immagini basta inserirle qui sotto

// Effettuo il preload
 if (document.images){
 immagine1= new Image(150,300);
 immagine1.src="immagini/scroll/001.png";
 }
  if (document.images){
 immagine2= new Image(150,300);
 immagine2.src="immagini/scroll/002.png";
 }
  if (document.images){
 immagine3= new Image(150,300);
 immagine3.src="immagini/scroll/003.png";
 }
  if (document.images){
 immagine4= new Image(150,300);
 immagine4.src="immagini/scroll/004.png";
 }

imageArray[0] = immagine1.src;
imageArray[1] = immagine2.src;
imageArray[2] = immagine3.src;
imageArray[3] = immagine4.src;



function colorapallina(n){

palla= 'p' + n;
document.getElementById(palla).src='immagini/scroll/piena.png';

//distruggipalle
for (g=0; g < (imageArray.length); g++)
{
 palla= 'p' + g;
 if (g != n) document.getElementById(palla).src='immagini/scroll/vuota.png';
}

}

function fadeout(value,i) {
  
value--;

document.getElementById(divID).style.opacity = value/10;
document.getElementById(divID).style.filter = 'alpha(opacity=' + value*10 + ')';

if(value > 0)
{
setTimeout('fadeout('+value+','+i+')',50);
}
else
{
i++;
if( i > (imageArray.length - 1) ) { i = 0; }
publishPicture(i);
}



}

function fadein(value) {
  
value++;

document.getElementById(divID).style.opacity = value/10;
document.getElementById(divID).style.filter = 'alpha(opacity=' + value*10 + ')';

if(value < 100)
{
setTimeout('fadein('+value+')',50);
}

}



function publishPicture(i) {
fadein(0);

document.getElementById(divID).style.backgroundRepeat = 'no-repeat';
document.getElementById(divID).style.backgroundPosition = 'right bottom';
document.getElementById(divID).style.backgroundImage = 'url("'+imageArray[i]+'")';
colorapallina(i);
setTimeout('fadeout('+100+','+i+')',ms);



}

// Fine Background slide

// POPUP

  function popup(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}

// POPUP


//BARRA DEI WIDGET

var stato = 1;

function initbar()
 {

if(document.documentElement.scrollWidth < 1150){ //caso schermo piccolo
  stato = 0;
  document.getElementById("contenuto_nascosto").style.display = "none";
  }
  else
  {
   document.getElementById("contenuto_nascosto").style.display = "block";
  }
}

function flipbar()
 {

 switch (stato) {
   case 1:
     document.getElementById("contenuto_nascosto").style.display = "none";
     stato = 0;
      break
   case 0:
      document.getElementById("contenuto_nascosto").style.display = "block";
      stato = 1 ;
      break
 }
 }

//BARRA DEI WIDGET


