var bugIndex = 0;
function initialize() {    
    totalSampleBugs = $$('.screenshot').length;
    slideshowTimer = setInterval(showNextBug, 5000);
}

function showPreviousBug() {
    //new Effect.Move($$('.screenshot')[bugIndex], {x: -600, y: 0, mode: 'relative'});
    $$('.screenshot')[bugIndex].hide();
    bugIndex--;
    
    if (bugIndex < 0) {
        bugIndex = totalSampleBugs - 1;
    }    
    $$('.screenshot')[bugIndex].show();

}

function showNextBug() {
    $$('.screenshot')[bugIndex].hide();
    bugIndex++;
    if (bugIndex >= totalSampleBugs) {
        bugIndex = 0;
    }    
    $$('.screenshot')[bugIndex].show();

}

function stopSlideshow() {
  try {
    clearInterval(slideshowTimer);
    slideshowTimer = null;
  } catch(ex) {

  }
}

Event.observe(window, 'load', initialize);