var WFOPHomepageSlideshow = Class.create({
  initialize: function(imageId, imagePaths)
    {
      if (imagePaths.length > 1) {

        this.imgElement = document.getElementById(imageId);

        if (this.imgElement) {

          this.imgPaths = imagePaths;

          /* preload all the images before starting */
          this.images = new Array();
          for (i = 0; i < imagePaths.length; i++) {
            var img = new Image();
            img.src = imagePaths[i];
            this.images.push(img);
          }

          this.show_image(0);
        }
      }
    },
  show_image: function(imgIndex)
    {
       if (imgIndex >= this.imgPaths.length)
         imgIndex = 0;

       this.imgElement.src = this.imgPaths[imgIndex];

       setTimeout(this.show_image.bind(this, imgIndex + 1), 5000);
    }
});
