// iphone slideshow
var Slideshow = Class.create();
Slideshow.prototype = {
    imageArray: [],
    activeImage: undefined,
    autoRotateInterval: 10,
    
    // initialize() runs on completion of the DOM loading. 
    initialize: function() {
      this.start();
    },

    rotate: function() {
      var next = this.imageArray.shift();
      this.imageArray.push(next);
      next.hide(); 
      for (var i = 0; i < this.imageArray.length; i++) {
        this.imageArray[i].style.zIndex = i;
      }
      next.appear({duration:0.5});
    },

    start: function() {
      var target = $('slideshow');
      this.imageArray = target.select('img[class=slideshow]');
      var slideshow = this;
      setInterval(function() { slideshow.rotate() }, 5000);
    }
  
};

document.observe('dom:loaded', function () { new Slideshow(); });

