<!--
function slide(src, link, tooltip, text, target, attr,text2,text3,id,MapLink1,MapLink2,MapLink3)
{
    this.src = src;
    this.link = link;
    this.text = text;
    this.text2 = text2;
    this.text3 = text3;
    
    this.MapLink1 = MapLink1;
    this.MapLink2 = MapLink2;
    this.MapLink3 = MapLink3;
    
    this.tooltip = tooltip;
    this.target = target;
    this.id = id;
    this.attr = attr;
    if (document.images)
        this.image = new Image();
    this.loaded = false;


    this.load = function()
    {
        if (!document.images)
            return;
        if (!this.loaded)
        {
            this.image.src = this.src;
            //this.image.usemap= this.MAP;
            //alert(this.MAP);
            this.loaded = true;
        }
    }


    this.getId = function()
    {
      return this.id;
    }

    this.hotlink = function()
    {
        var mywindow;
        if (!this.link)
            return;
        if (this.target)
        {
            if (this.attr)
                mywindow = window.open(this.link, this.target, this.attr);
            else
                mywindow = window.open(this.link, this.target);
            if (mywindow && mywindow.focus)
                mywindow.focus();
        }
        else
            location.href = this.link;
    }
}

// Visualizzatore di slides
function slideshow(slideshowname)
{
    this.name = slideshowname;
    this.slides = new Array();  // array delle slides da visualizzare
    this.current = 0;           // indice della slide attuale
    this.timeoutid = 0;         // timer
    this.timeout = 3000;        // intervallo tra la visualizzazione delle slides
    this.repeat = true;         // indica se deve ciclare tra le slides
    this.image;                 // immagine visualizzata
    this.textid;                // eventuale elemento html da aggiornare al cambio slide
    this.textid2;               // eventuale elemento html da aggiornare al cambio slide
    this.textid3;               // eventuale elemento html da aggiornare al cambio slide
    this.textarea;              // eventuale textarea da aggiornare al cambio slide
    this.prefetch = -1;
    this.slidesRel = false;

    // aggiunge una slides
    this.add_slide = function(slide)
    {
       var i = this.slides.length;
       if (this.prefetch == -1)
            slide.load();
        this.slides[i] = slide;
    }

    // attiva il timer
    this.play = function(timeout)
    {
        this.pause();
        if (timeout)
            this.timeout = timeout;
        if (typeof this.slides[ this.current ].timeout != 'undefined')
            timeout = this.slides[ this.current ].timeout;
        else
            timeout = this.timeout;
        this.timeoutid = setTimeout(this.name + ".loop()", timeout);
    }

    // ferma il timer
    this.pause = function()
    {
        if (this.timeoutid != 0)
        {
            clearTimeout(this.timeoutid);
            this.timeoutid = 0;
        }
    }

    // si posiziona sulla slide successiva e riattiva il timer
    this.loop = function()
    {
        if (this.current < this.slides.length - 1)
        {
            next_slide = this.slides[this.current + 1];
            if (next_slide.image.complete == null || next_slide.image.complete)
                this.next();
        }
        else
            this.next();
        this.play();
    }


    this.valid_image = function()
    {
        if (!this.image)
            return false;
        else
            return true;
    }

    // Visualizza l'immagine attuale
    this.update = function()
    {
        if (!this.valid_image())
            return;
        if (typeof this.pre_update_hook == 'function')
            this.pre_update_hook();

        // slide attuale
        var slide = this.slides[ this.current ];

        // verifica se il browser supporta i filtri
        var dofilter = false;
        if (this.image && typeof this.image.filters != 'undefined' && typeof this.image.filters[0] != 'undefined')
            dofilter = true;

       // Legge l'immagine
        slide.load();

        // Applica i filtri per il cambio immagine
        if (dofilter)
        {
            // imposta il filtro se specificato
            if (slide.filter && this.image.style && this.image.style.filter)
                this.image.style.filter = slide.filter;
            this.image.filters[0].Apply();
        }

       // aggiorna l'immagine
        this.image.src = slide.image.src;
        this.image.alt = this.slides[ this.current ].tooltip;


        if (this.slides[ this.current ].MapLink1!="")
        {
            document.all.vetrina.innerHTML = '' +
           '<area shape=\"rect\" alt=\"\" coords=\"393,0,604,150\" href=\"' + this.slides[ this.current ].MapLink1 + '\">' +
           '<area shape=\"rect\" alt=\"\" coords=\"181,0,392,150\" href=\"' + this.slides[ this.current ].MapLink2 + '\">' +
           '<area shape=\"rect\" alt=\"\" coords=\"0,0,181,150\" href=\"' + this.slides[ this.current ].MapLink3 + '\">';
       }

        // attiva il filtro
        if (dofilter)
            this.image.filters[0].Play();

        // aggiorna il testo
        this.display_text();

        if (typeof this.post_update_hook == 'function')
            this.post_update_hook();

        // Pre-carica le immagini
        if (this.prefetch > 0)
        {
            var next, prev, count;

            next = this.current;
            prev = this.current;
            count = 0;
            do
            {
                // prende l'immagine precedente e la successiva
                if (++next >= this.slides.length) next = 0;
                if (--prev < 0) prev = this.slides.length - 1;

                // Precarica l'immagine
                this.slides[next].load();
                this.slides[prev].load();
            } while (++count < this.prefetch);
        }
        if (this.slidesRel)
          SLIDES.goto_slide_id(this.slides[ this.current ].id);
   }

    // Salta alla slide richiesta
    // utilizare -1 per arrivare all'ultima slide
    this.goto_slide = function(n)
    {
        if (n == -1)
            n = this.slides.length - 1;

        if (n < this.slides.length && n >= 0)
            this.current = n;
        this.update();
    }

    // Salta alla slide con l'id richiesto richiesta
    this.goto_slide_id = function(id)
    {
        for (n=0; n<this.slides.length; n++)
        {
          if (this.slides[n].id == id)
            this.goto_slide(n);
        }
    }


    // Posiziona su una slide casuale (esclusa l'attuale) e la visualizza
    this.goto_random_slide = function(include_current)
    {
        var i;

        if (this.slides.length > 1)
        {
           // Genera un numero casuale
            do
            {
                i = Math.floor(Math.random() * this.slides.length);
            } while (i == this.current);
            // Visualizza la slide
        }
        else
            i = 0;
        this.goto_slide(i);
    }


    // si posiziona sulla slide successiva
    this.next = function()
    {
        if (this.current < this.slides.length - 1)
            this.current++;
        else if (this.repeat)
            this.current = 0;
        this.update();
    }


    // si posiziona sulla slide precedente
    this.previous = function()
    {
        if (this.current > 0)
            this.current--;
        else if (this.repeat)
            this.current = this.slides.length - 1;
        this.update();
    }


    // Modifica in modo casuale l'ordine di visualizzazione delle slides
    this.shuffle = function()
    {
        var i, i2, slides_copy, slides_randomized;

        // crea una copia dell'array contenente le slides in ordine
        slides_copy = new Array();
        for (i = 0; i < this.slides.length; i++)
            slides_copy[i] = this.slides[i];

        // crea un nuovo array per contenete le slides in ordine casuale
        slides_randomized = new Array();

        do
        {
            // preleva una slide casuale tra le rimanenti
            i = Math.floor(Math.random() * slides_copy.length);

            // aggiunge la slide alla fine del nuovo array
            slides_randomized[ slides_randomized.length ] = slides_copy[i];

            // rimuove la slide dall'array ordinato
            for (i2 = i + 1; i2 < slides_copy.length; i2++)
                slides_copy[i2 - 1] = slides_copy[i2];
            slides_copy.length--;

        } while (slides_copy.length);

        // imposta l'array ordinato casualmente
        this.slides = slides_randomized;
    }


    // restituisce il testo della slide corrente
    this.get_text = function()
    {
        return(this.slides[ this.current ].text);
    }

    // restituisce il tooltip della slide corrente
    this.get_tooltip = function()
    {
    	 
    	
    	
        return(this.slides[ this.current ].tooltip);
    }

    // restituisce il src della slide corrente
    this.get_img = function()
    {
        return(this.slides[ this.current ].src);
    }

    // Restistuisce i testi di tutte le slides intervallati
    // dai testi passati come parametri
    this.get_all_text = function(before_slide, after_slide)
    {
        all_text = "";

        for (i = 0; i < this.slides.length; i++)
        {
            slide = this.slides[i];
            if (slide.text)
                all_text += before_slide + slide.text + after_slide;
        }
        return(all_text);
    }

    // Visualizza il testo della slide corrente
    // Se il parametro "text" non θ valorizzato utilizza il
    // testo della slide
    this.display_text = function(text)
    {
        if (!text)
            text = this.slides[ this.current ].text;

        // Se esiste una textarea cambia il testo visualizzato
        if (this.textarea && typeof this.textarea.value != 'undefined')
            this.textarea.value = text;

        // Se esiste un test id cambia il contenuto dell'elemento HTML
        if (this.textid)
        {
            r = this.getElementById(this.textid);
            if (!r)
                return false;
            if (typeof r.innerHTML == 'undefined')
                return false;
            r.innerHTML = text;
        }

        // Se esiste un 2°test id cambia il contenuto dell'elemento HTML
        if (this.textid2)
        {
            text2 = this.slides[ this.current ].text2;
            r = this.getElementById(this.textid2);
            if (!r)
                return false;
            if (typeof r.innerHTML == 'undefined')
                return false;
            r.innerHTML = text2;
        }

        // Se esiste un 3°test id cambia il contenuto dell'elemento HTML
        if (this.textid3)
        {
            text3 = this.slides[ this.current ].text3;
            r = this.getElementById(this.textid3);
            if (!r)
                return false;
            if (typeof r.innerHTML == 'undefined')
                return false;
            r.innerHTML = text3;
        }
    }

    // richiama il metodo hotlink() della slide attuale
    this.hotlink = function()
    {
        this.slides[ this.current ].hotlink();
    }


    // Salva la posizione attuale in un cookie, in modo da memorizzarlo
    // per visite successive
    this.save_position = function(cookiename)
    {
        if (!cookiename)
            cookiename = this.name + '_slideshow';
        document.cookie = cookiename + '=' + this.current;
    }


    // Se θ stato precedentemente utilizzata la funzione slideshow_save_position(),
    // si riposiziona sulla slide indicata
    this.restore_position = function(cookiename)
    {
        if (!cookiename)
            cookiename = this.name + '_slideshow';

        var search = cookiename + "=";

        if (document.cookie.length > 0)
        {
            offset = document.cookie.indexOf(search);
            // se il cookie esiste
            if (offset != -1)
            {
                offset += search.length;
                end = document.cookie.indexOf(";", offset);
                if (end == -1) end = document.cookie.length;
                this.current = parseInt(unescape(document.cookie.substring(offset, end)));
            }
        }
    }

    this.getElementById = function(element_id)
    {
        if (document.getElementById)
            return document.getElementById(element_id);
        else if (document.all)
            return document.all[element_id];
        else if (document.layers)
            return document.layers[element_id];
        else
            return undefined;
    }


    this.set_image = function(imageobject)
    {
        if (!document.images)
            return;
        this.image = imageobject;
    }

    this.set_textarea = function(textareaobject)
    {

        this.textarea = textareaobject;
        this.display_text();
    }

    this.set_textid = function(textidstr)
    {

        this.textid = textidstr;
        this.display_text();
    }
}
// -->





