var Tabs = new Class({
	Implements: Options,
	options: {
		active: 0
	},
	initialize: function(container, togglers, tabs, options){
		this.setOptions(options);
		this.container = $(container) || false;
		this.togglers = (togglers || this.container.getElements('div.tabs a') || []);
		this.tabs = (tabs || this.container.getElements('div.tab') || []);
		this.count = this.togglers.length;
		this.setup();
	},
	setup: function(){
		this.show(false, this.options.active);
		this.togglers.each(function(el, i){
			el.addEvent('click', this.show.bindWithEvent(this, i))
		}.bind(this));
	},
	show: function(e, sel){
		if(e) e.stop();
		for(var i = 0; i < this.count; i++){
			this.deactivate(i);
		}
		this.activate(sel);
		this.options.active = sel;
	},
	deactivate: function(pos){
		if(this.count) {
			this.togglers[pos].removeClass('active');
			this.tabs[pos].removeClass('active');
		}
	},
	activate: function(pos){
		if(this.count) {	
			this.togglers[pos].addClass('active');
			this.tabs[pos].addClass('active');
		}
	}
});
