window.addEvent('load', function() { 
  (function() {

    var entries = $$('.entry')
    var current = 0
    

    
    var hide_all = function(e) {      
      entries.each(function(e) {
        e.setStyle('opacity', 0.0)
        e.setStyle('display', 'none')
      })
    }
    
    var show = function(next) {
      next = (current + 1 == entries.length) ? 0 : current + 1
      var e = entries[next]
      var c = entries[current] 
      
      hide_current = new Fx.Tween(c, { transition:Fx.Transitions.Sine.easeInOut, duration: 500, link: 'chain'}) 
      
      hide_current.start('opacity', 0.0).chain(function() {
        c.setStyle('display', 'none')
        e.setStyle('display', 'block')
        
        show_new = new Fx.Tween(e, { transition:Fx.Transitions.Sine.easeInOut, duration: 800, link: 'chain'}) 
        show_new.start('opacity', 1.0).chain(function() {
          current = next          
        })

      })
    }
    
    var show_next = function() {
      show()      
      
    }
    
    hide_all()
    // entries[0].show()
    show(0)
    
    show_next.periodical(12000, this);
    
  })()
})    