var animationsbox;
Event.observe(window, 'load', function() {  

  //nextbox();
  animationsbox = $('animationsbox');
  window.setInterval('nextbox()', 5000);
});

function nextbox(){
  var boxes = $$('.movebox');
  var box = boxes[boxes.length-1];
  boxes[boxes.length-2].show();
  
  Effect.Fade(
    box,
    {
      afterFinish: function() {
        box.remove(); 
        animationsbox.insert({top: box});
        //box.show();
      },
      duration: 2
    }
  );
 
  /*
  new Effect.Move(
    boxes[1],{
    afterFinish: function() {
        boxes[0].remove(); 
        animationsbox.insert({bottom: boxes[0]});
         boxes[0].setStyle({
          left:0
        });
       
      },
    x: -310, y: 0, mode: 'relative'}
  );
   */ 
   
}
