var SlideShow = new Class({
	
	Implements: Options,
	
	options: {
		fxDuration: 500,
		period: 3000
	},
	
	initialize: function(container, options) {
		this.container = $(container);
		this.container.setStyle("position", "relative");
		this.setOptions(options);
		this.pictures = this.container.getChildren();
		for(var i=0; i<this.pictures.length; i++) {
			var pic = this.pictures[i];
			pic.setStyles({
				"position": "absolute",
				"visibility": (i == 0 ? "visible": "hidden"),
				"top": 0,
				"left": 0
			});
			pic.set("morph", {
				duration: this.options.fxDuration
			});
		}
		this.selectedPicIndex = 0;
		if(this.pictures.length > 1) {
			this.startSlideShow.periodical(this.options.period, this);
		}
	},
	
	startSlideShow: function() {
		this.hidePic(this.selectedPicIndex);
		this.selectedPicIndex = (this.selectedPicIndex == this.pictures.length - 1 ? 0 : this.selectedPicIndex + 1);
		this.showPic(this.selectedPicIndex);
	},
	
	showPic: function(index) {
		this.pictures[index].morph({
			"opacity": [0, 1]
		});
	},
	
	hidePic: function(index) {
		this.pictures[index].morph({
			"opacity": [1, 0]
		});
	}
	
});
