/**
 * kSlideshow
 *
 * Author: Kramer <kramersCode@kramers.ws>
 * Date:
 *
 * @see prototype.js
 **/
kSlideshow = Class.create();
kSlideshow.prototype = {
	initialize: function(s) {
		this.x = {}; // Garbage container
		this.settings = s;
		this.s = {
			delay: 500, // Expressed in miliseconds
			el: null,
			currentSlide: 0,
			slides: []
		}
		for (var key in s) this.s[key] = s[key];

		this.getAllSlides();
		this.showSlide(this.s.currentSlide);
		if (this.s.delay > 0) setInterval(this.showNextSlide.bind(this), this.s.delay);
	},

	// PUBLIC
	showNextSlide: function() {
		this.s.currentSlide++;
		if (this.s.currentSlide > this.s.slides.length-1) this.s.currentSlide = 0;
		this.showSlide(this.s.currentSlide);
	},

	showSlide: function(num) {
		this.hideAllSlides();
		this.s.slides[num].style.display = 'block';
	},

	hideAllSlides: function() {
		for (var x=0; x<this.s.slides.length; x++) {
			this.s.slides[x].style.display = 'none';
		}
	},

	// PRIVATE
	getAllSlides: function() {
		this.s.slides = this.s.el.getElementsByTagName('li');
	}
}
