var YOOgalleryslides = new Class({

	initialize: function(container){
		this.index = 0;
		this.container = $(container);
		this.thumbnails = this.container.getElements('.thumbnail');
		this.caption = this.container.getElement('div.navigation span.caption');
		this.container.getElement('div.navigation div.right').addEvent('click', this.nextSlide.bindWithEvent(this));
		this.container.getElement('div.navigation div.left').addEvent('click', this.prevSlide.bindWithEvent(this));
		this.showSlide(0);
	},

	nextSlide: function(){
		if (this.index + 1 >= this.thumbnails.length) {
			this.index = 0;
		} else {
			this.index++;
		}
		this.showSlide(this.index);
	},

	prevSlide: function(){
		if (this.index - 1 < 0) {
			this.index = this.thumbnails.length - 1;
		} else {
			this.index--;
		}
		this.showSlide(this.index);
	},
	
	showSlide: function(index){
		this.caption.setHTML('foto ' + (index+1) + ' di ' + this.thumbnails.length);
		this.thumbnails.each(function(el, i) {
			if (i == index) {
				el.setStyle('display', 'block');
			} else {
				el.setStyle('display', 'none');
			}
		});
	}

});
