// tabbed elements {{{1
// sexy tabs with any element e.g. table, div
// 
// naming conventions:
//
// * tabs must have class of 'tab'
// * tabs must have ids starting 'tab_1'
// * elements to tab must have class of 'tabbed_element'
// * elements to tab must have ids starting 'tabbed_element_1'
// * set the first tab as selected with class 'active'
// * set the first tabbed element as selected with class 'first'

var tabbed_elements = {
    // hide all tabbed elements except first
    // and set active state for first
    '.tabbed_element': function(element) {
        if (!element.hasClassName('first')) {
            Element.toggle(element);
        }
    },

    // set onclicks for tabs
    '.tab:click': function(element, event) {
        tabbed_element = $('tabbed_element_' + element.id.substring(4));

        // hide all tab elements except newly tabbed one
        $$('.tabbed_element').each( function(element){
                Element.hide(element);
                });
        Element.show(tabbed_element);

        // set tab active states
        $$('.tab').each( function(tab){
                tab.removeClassName('active');
                });
        element.addClassName('active');

        Event.stop(event);
    }
}
// }}}1
