var Fade = Class.create();
	Fade.prototype = {
	interval: 6,   
	items: [],
	currentItemIndex: 0,
	currentItem:null,
	timer: null,
  
  
  initialize: function(){
    this.container = $('Fade');
    this.container.style.visibility = 'visible';
    
    for (var i=0, arg; arg = arguments[i]; i++){
      var item = $(arg);
      this.container.appendChild(item.remove());
      this.items.push({
        image: item.down('.image').hide(),
      	 trocar: item.down('.trocar').hide()
      });
    }
    
    this.reveal(this.items[0]);
    
    setInterval(this.poll.bind(this), this.interval*1000);
  },
  
 
  poll: function(){
    
    if (++this.currentItemIndex >= this.items.length) this.currentItemIndex = 0;
    this.reveal(this.items[this.currentItemIndex]);
  },
  
  reveal: function(item){
    
    if (this.currentItem){ this.hide(item); return }
    
   var show = function(){ 
      new Effect.Appear(item.trocar);
    }
    item.image.style.zIndex = 2;
   new Effect.Appear(item.image, {afterFinish:show});
        
    this.currentItem = item;
  },
  
  hide: function(itemToShow){
    var finish = function(){
      this.currentItem.image.style.zIndex = 1;
      new Effect.Fade(this.currentItem.image);
      this.currentItem = null;
      this.reveal(itemToShow);
    }.bind(this);
    
    new Effect.Fade(this.currentItem.trocar, {afterFinish: finish, duration:0.5});
    }
}