var Slideshow = Class.create();
Slideshow.prototype = {
  initialize: function(imagesList) {
    this.start(imagesList);
  },
  start: function(imagesList) {
    var index = Math.floor(Math.random() * imagesList.size());
    new PeriodicalExecuter(function(pe) {
      //new Effect.Appear('slideShowItemContainer');
      $('showImage').src = "/images/" + imagesList[index];
      if (index < 11) {
        index++;
      }
      else {
        index = 0;
      }
    }, 5);
  }
};

addOnLoadListener(function() {
  //var list = ['iPic1.jpg', 'iPic2.jpg', 'iPic3.jpg', 'iPic4.jpg', 'iPic5.jpg', 'iPic6.jpg', 'iPic7.jpg', 'iPic8.jpg', 'iPic9.jpg', 'iPic10.jpg'];
  var list = ['iPic11.jpg', 'iPic12.jpg', 'iPic13.jpg', 'iPic14.jpg', 'iPic15.jpg', 'iPic16.jpg', 'iPic17.jpg', 'iPic18.jpg', 'iPic19.jpg', 'iPic20.jpg', 'iPic21.jpg', 'iPic22.jpg'];
  preloadImages(list);
  var show = new Slideshow(list);
});

function preloadImages(list) {
  var folder = 'images/';
  list.each(function(item) {
		var image = new Image();
		image.src = folder + item;
  });
}
