/* simple tabs */
(function($){
jQuery.fn.maketabs = function(settings){
    settings = jQuery.extend({
        active: null,
        onOpen: function(){}
    }, settings);

    this.each(function(){
        var box = $(this),
            nav = $('<div/>').addClass('tab-nav'),
            active;
        box.children('.tab')
           .children('.tab-title').remove().appendTo(nav);
        nav.children(':first').addClass('tab-active');
        nav.prependTo(box);
        if (settings.active == null){
            active = box.children('.tab-active');
            if (!active.size())
                active = box.children('.tab:first');
        } else {
            active = box.children('.tab').eq(settings.active);
        }
        active.show();
        box.children('.tab').not(active).hide();
        nav.delegate('.tab-title:not(.tab-active)', 'click', function(){
            var $this = $(this),
                index = $this.index(),
                el = box.children('.tab').hide().eq(index).show();
            $this.addClass('tab-active').siblings().removeClass('tab-active');
            settings.onOpen(el, index);
        });
        settings.onOpen(active, active.index());
    });
};
})(jQuery);

