var FabtabsPic = Class.create();
var heightActivTabs = 0;
var heightContent = null;

FabtabsPic.prototype = {
	initialize : function(element) {
        if (!heightActivTabs) {
            heightContent = document.getElementById("content_enclosure").offsetHeight;
        }
        this.element = $(element);
		var options = Object.extend({}, arguments[1] || {});
		this.menu = $A(this.element.getElementsByTagName('a'));
		this.show(this.getInitialTab());
		this.menu.each(this.setupTab.bind(this));
    },
	setupTab : function(elm) {
		Event.observe(elm,'click',this.activate.bindAsEventListener(this),false)
        /*Start for height columns*/
        heightActivTabs += $(this.tabID(elm)).offsetHeight;
        /*if (heightActivTabs != 0) {
            matchColumns(heightContent + heightActivTabs,'');
        }*/
        /*End for height columns*/
    },
	activate :  function(ev) {
		var elm = Event.findElement(ev, "a");
		Event.stop(ev);
		this.show(elm);
		this.menu.without(elm).each(this.hide.bind(this));
    },
	hide : function(elm) {
		$(elm).removeClassName('pushed');
		$(this.tabID(elm)).removeClassName('activeTabBody');
    },
	show : function(elm) {
		$(elm).addClassName('pushed');
		$(this.tabID(elm)).addClassName('activeTabBody');
    },
	tabID : function(elm) {
		return elm.href.match(/#(\w.+)/)[1];
    },
	getInitialTab : function() {
		if(document.location.href.match(/#(\w.+)/)) {
			var loc = RegExp.$1;
			var elm = this.menu.find(function(value) { return value.href.match(/#(\w.+)/)[1] == loc; });
			return elm || this.menu.first();
        } else {
			return this.menu.first();
        }
    }


}