
var SlideShow = Class.create(
		{
			initialize: function() {
				this.slideShowImages = $$("img.slideshowimage");
				this.pauseTime = 5000;
				this._durationTime = 2;
				this._currentIndex = 0;
			},
			
			start: function(pauseTime) {
				this.pause = pauseTime;
				
				if (this.slideShowImages.length > 0)
					this._doTimer();
			},
			
			_doTimer: function() {
				setTimeout(this._doEffect.bind(this), this.pause);
			},
			
			_doEffect: function() {
				
				Effect.Fade(this.slideShowImages[this._currentIndex], {
					duration: this._durationTime
				});

				this._currentIndex++;
				
				if (this._currentIndex >= this.slideShowImages.length)
					this._currentIndex = 0;
				
				Effect.Appear(this.slideShowImages[this._currentIndex], {
					duration: this._durationTime
				});
				
				this._doTimer();
			}
		});


Event.observe(window, 'load', function()
		{
			mySlideShow = new SlideShow();
			mySlideShow.start(6000);
		});

