var TabManager = Class.create();
TabManager.prototype = {
    
    initialize: function(className, currentTab, options) {
        this.currTab = currentTab;
        
        document.getElementsByClassName(className).each(function(elm) {
            Event.observe(elm, 'click', this.swap.bindAsEventListener(this));
        }.bind(this));
        
        // handle call backs
        if (options && options.blur) {
            this.blur = options.blur;
        }
        
        if (options && options.focus) {
            this.focus = options.focus;
        }
    },
    
    swapUnknown: function(tab_name) {
        tab_name = tab_name.replace('tab_', '');
        
        $('panel_' + this.currTab).hide();
        (this.blur || Prototype.emptyFunction)(this.currTab);
        
        $('panel_' + tab_name).show();
        (this.focus || Prototype.emptyFunction)(tab_name);
        
        this.currTab = tab_name;
    },
    
    swap: function(evt) {
        tab_name = Event.element(evt).id.replace('tab_', '');
        
        $('panel_' + this.currTab).hide();
        (this.blur || Prototype.emptyFunction)(this.currTab);
        
        $('panel_' + tab_name).show();
        (this.focus || Prototype.emptyFunction)(tab_name);
        
        this.currTab = tab_name;
    }
}