/**
 * ImageCycle
 */
var ImageCycle = Class.create({
	/**
	 * Init ImageCycle
	 */
	initialize: function(images, nDelay) {
		this.images = images;
		this.nDelay = nDelay;
	  
		this.nCurrImage = 0;
				
		if (this.images.length) {
		  this.showImage();
		}
	},
	
	showImage: function() {
	  var elemImg = this.images[this.nCurrImage];
		elemImg.style.display = "inline";
		elemImg.style.visibility = "visible";
	  elemImg.setOpacity(0);
	  
	  // fade on
    Effect.Fade(elemImg, { duration: 2, from: 0, to: 1 });
    // start timer for next slide
    this.nextImage.bind(this).delay(this.nDelay);
  },
	
	nextImage: function() {
	  var elemImg = this.images[this.nCurrImage];
    // fade off	  
    Effect.Fade(elemImg, { duration: 2, from: 1, to: 0 });
	  
    if (this.nCurrImage+1 < this.images.length) {
      this.nCurrImage++;
    }
    else {
      this.nCurrImage = 0;
    }
    
	  this.showImage();
	}
	
});
