var current_pos = 0;
var scroll = false;

var carousel = {

  moveTab : function()
  {
    pos = carousel.nextTabId();
    scroll.toElement($(carousel.currentTabId(pos)).id);
  },
  nextTabId : function()
  {
    var frameCount = $$('#panorama .frame').length;
    if(current_pos >= frameCount){
      current_pos = 1;
    }
    else
      current_pos = current_pos + 1;
    return current_pos;
  },
  currentTabId : function(tabNumber)
  {
    return 'frame'+tabNumber;
  },
  init : function()
  {
     scroll = new Fx.Scroll('panorama', {
        wait: false,
        duration: 1200,
        offset: {'x': 0, 'y': -0 },
        transition: Fx.Transitions.Quad.easeInOut
    });
    var frames = $$('#panorama .frame');
      scroll.toElement(frames[0].id);
    carousel.moveTab.periodical(8000); 
  }
}

window.addEvent('domready', carousel.init);
