﻿
window.addEvent('domready', function() { 

    var countBacheca=0;
    var elBacheca = $$('.cssDivCorpo_CorpoDx_dx_content');
    var timerInterval;
    
    elBacheca[countBacheca].setStyle('opacity','0');
    elBacheca[countBacheca].setStyle('display','inline-block');
    
    var alphaBacheca = new Fx.Morph(elBacheca[countBacheca], {duration: 500, transition: Fx.Transitions.Sine.easeOut});
    alphaBacheca.start({
        'opacity': ['0','1']
    });
    
    $$('.cssDivProg_content').setStyle('opacity',0.7);
    $$('.cssDivProg_content').addEvent('mouseover',function(){
        this.setStyle('opacity',1);
    });
    
    $$('.cssDivProg_content').addEvent('mouseout',function(){
        this.setStyle('opacity',0.7);
    });
    
    $$('.cssDivCorpo_CorpoDx_dx_container').addEvent('mouseover',function(){
        clearInterval(timerInterval);
    });
    
    $$('.cssDivCorpo_CorpoDx_dx_container').addEvent('mouseout',function(){
        CiclaFoglio();
    });
    
    function CiclaFoglio(){
        timerInterval = setInterval(function() {
            
            var alphaBachecaOld = new Fx.Morph(elBacheca[countBacheca], {duration: 500, transition: Fx.Transitions.Sine.easeOut});
            alphaBachecaOld.start({
                'opacity': ['1','0']
            }).chain(function(){
                
                elBacheca[countBacheca].setStyle('display','none');
            
                countBacheca +=1;
                if (elBacheca.length == countBacheca) {
                    countBacheca = 0;
                }
                
                elBacheca[countBacheca].setStyle('opacity','0');
                elBacheca[countBacheca].setStyle('display','inline-block');
                
                var alphaBachecaNew = new Fx.Morph(elBacheca[countBacheca], {duration: 500, transition: Fx.Transitions.Sine.easeOut});
                alphaBachecaNew.start({
                    'opacity': ['0','1']
                });
                
            });
            
        },5000);
    }
    CiclaFoglio();
    
});
