var contentBrowser = new Class({

	current: null,

	initialize: function(container, elements)
	{
		this.container = $(container);
		this.elements = $$(elements);

		this.createButtons();

		this.show(0);
	},
	
	show: function(n)
	{
		this.current = n;
		this.elements.each(function(el, i){
			el.setStyle('display', i == n ? '' : 'none');
		});
		this.updateButtons();
	},
	
	previous: function()
	{
		var p = this.current - 1 >= 0 ? this.current - 1 : this.elements.length - 1;
		this.show(p);
	},
	
	next: function()
	{
		var n = this.current + 1 < this.elements.length  ? this.current +1 : 0;
		this.show(n);
	},

	createButtons: function()
	{
		this.btn_prev = new Element('a', {
			'class': 'prev',
			href: '#'
		}).addEvent('click', function(e){
			e.stop();
			this.previous();	
		}.bind(this)).inject(this.container);

		this.container.inject(this.btn_prev);

		this.btn_next = new Element('a', {
			'class': 'next',
			href: '#'
		}).addEvent('click', function(e){
			e.stop();
			this.next();	
		}.bind(this)).inject(this.container);
	},

	updateButtons: function()
	{
		var p = this.current - 1 >= 0 ? this.current - 1 : this.elements.length - 1;

		this.btn_prev.set('html', this.elements[p].select('span')[0].innerHTML);

		var n = this.current + 1 < this.elements.length  ? this.current +1 : 0;

		this.btn_next.set('html', this.elements[n].select('span')[0].innerHTML);
	}

});

/*
window.addEvent('domready', function(){
	


});
*/
