var SimpleSlideshow = new Class({
    options: {
	showDuration: 4000
    },
    Implements: [Options,Events],
    initialize: function(container,elements,options) {
	this.container = $(container);
	this.elements = $$(elements);
	this.currentIndex = 0;
	this.interval = '';
	
	this.elements.each(function(el,i){
	    if(i > 0) el.set('opacity',0);
	},this);
	
	this.container.addEvents({
	    mouseenter: function() { this.stop(); }.bind(this),
	    mouseleave: function() { this.start(); }.bind(this)
	});
    },
    show: function(to) {
	this.elements[this.currentIndex].fade('out');
	this.currentIndex = ($defined(to) ? to : (this.currentIndex < this.elements.length - 1 ? this.currentIndex + 1 : 0));
	this.elements[this.currentIndex].fade('in');
    },
    start: function() {
	this.interval = this.show.bind(this).periodical(this.options.showDuration);
    },
    stop: function() {
	$clear(this.interval);
    },
    next: function() {
    	this.stop();
    	this.show();
    },
    prev: function() {
	this.stop();
	this.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);
    }
});
