//*******************************************************************
//* File      : banner.js
//* Creato il : 30/06/2007 - ultimo aggiornamento il 4/04/2010
//* Autore    : Graziano Fasano graziano@fgpsoftware.it
//*
//* Avviso: La riproduzione o distribuzione non autorizzata di queste 
//* pagine o di parte di esse, sarà perseguibile civilmente e 
//* penalmente.
//*******************************************************************

function photosliderObj (name,ritardo,defaultpath,transizioni){
 this.name=name;
 this.foto=new Array();
 this.testo=new Array();
 this.effetto=new Array();
 this.addfoto=addfoto;
 this.cambiafoto=cambiafoto2;
 this.which=-1;
 this.prece=-1;
 this.ritardo = ritardo;
 this.numerofoto=numerofoto;
 this.defaultpath=defaultpath;
 this.pausa=pausa;
 this.timer=0;
 this.precedente=precedente;
 this.vai=vai;
 this.start=start;
 this.transizioni = transizioni;
}

function addfoto (nomefile,testo,link,effetto) {
 this.foto[this.foto.length] = nomefile;
 this.testo[this.testo.length] = testo;
 this.effetto[this.effetto.length] = effetto;
 if (document.getElementById(this.name+'Elenco') != null) {
  option = new Option(this.foto.length,this.foto.length);
  document.getElementById(this.name+'Elenco').options[document.getElementById(this.name+'Elenco').options.length] = option;
 }
}

function cambiafoto2(noprece) {
 window.clearTimeout(this.timer);
 if (document.getElementById(this.name+'PhotoSlider') != null){
  if (document.getElementById(this.name+'PhotoSlider').complete == true){
   if (document.getElementById(this.name+'BtnPause') != null) document.getElementById(this.name+'BtnPause').style.display='block';
   if (document.getElementById(this.name+'BtnPlay') != null) document.getElementById(this.name+'BtnPlay').style.display='none';
   if (noprece != true) this.prece=this.which;
   if (this.which<this.foto.length-1){
    this.which++;
   }
   else
   {
    this.which=0;
   }
   if (document.getElementById(this.name+'Elenco') != null) document.getElementById(this.name+'Elenco').selectedIndex = this.which
   if (this.transizioni > 0) {
    if (document.all){
     document.getElementById(this.name+'PhotoSlider').filters.revealTrans.Transition=parseInt(this.effetto[this.which]);
//Math.floor(Math.random()*23);
     document.getElementById(this.name+'PhotoSlider').filters.revealTrans.stop();
     document.getElementById(this.name+'PhotoSlider').filters.revealTrans.apply();
    }
   }
   document.getElementById(this.name+'PhotoSlider').src=this.defaultpath+this.foto[this.which];
   if (document.getElementById('annotazioni') != null) document.all.annotazioni.innerHTML=this.testo[this.which];
   if (this.prece >= 0) {
    if (document.getElementById('annotazione'+String(this.prece+1)) != null) {
     document.getElementById('annotazione'+String(this.prece+1)).style.display='none';
    }
   }
   if (document.getElementById('annotazione'+String(this.which+1)) != null) document.getElementById('annotazione'+String(this.which+1)).style.display='block';
   if (this.transizioni > 0) {
    if (document.all) document.getElementById(this.name+'PhotoSlider').filters.revealTrans.play(this.transizioni);
   }
  }
 }
 this.timer=window.setTimeout(this.name+'.cambiafoto()',this.ritardo);
}

function numerofoto () {
 document.write(this.foto.length);
}

function pausa () {
 window.clearTimeout(this.timer);
 if (document.getElementById(this.name+'BtnPause') != null) document.getElementById(this.name+'BtnPause').style.display='none';
 if (document.getElementById(this.name+'BtnPlay') != null) document.getElementById(this.name+'BtnPlay').style.display='block';
}

function precedente() {
 this.prece=this.which;
 this.which--;
 if (this.which<0) this.which=this.foto.length-1;
 this.which--;
 this.cambiafoto(true);
}

function vai(num) {
 this.prece=this.which;
 this.which=num-2;
 if (this.which<0) this.which=this.foto.length-1;
 this.cambiafoto(true);
}

function start () {
 if (document.getElementById(this.name+'Totale') != null) document.getElementById(this.name+'Totale').innerHTML=this.foto.length;
 this.cambiafoto();
}