
if(!FYH) var FYH = {};


FYH.initialize = function(){
    // Normalize column heights. 
    ['top', 'bottom'].each(function(section){
        var columns = $$('.' + section + ' .col'), 
        max_height = columns.max(function(column){
            return column.getHeight();
        });
        if(!max_height) return;
        columns.each(function(column){
            column.setStyle({'min_height': px(max_height) });
        });
    });
    
    // Build image captions
    $$('img').each(function(image){
        if(!image.alt) return;
        
        var wrapper = new Element('div', {'class':'image'});
        image.wrap(wrapper);
        wrapper.insert({
            bottom: new Element('p').update(image.alt)
        });
    });
};

$(document).observe('dom:loaded', FYH.initialize);


FYH.TabbedModule = Class.create({
    initialize: function(element){
        this.element = $(element);
        this.tabs = this.element.select('.tabs li');
        this.pages = this.element.select('.content');
        this.tabs.first().addClassName('active');
        
        this.tabs.each(function(tab, i){
            tab.observe('click', function(){
                this.pages.invoke('hide');
                this.pages[i].show();
                
                this.tabs.invoke('removeClassName', 'active');
                this.tabs[i].addClassName('active');
            }.bind(this));
        }.bind(this));
    }
});


