jQuery.fn.nbtabs = function () {
    return this.each (function () {
        var obj = $(this);
        // Find all tabs
        $(obj).find('a').each(function(){
            $(this).click(function(){
                var tabIdOpen = '#' + $(this).attr('rel');
                // Clicked tab isn't open yet
                if (!$(tabIdOpen).hasClass('tabOpen')) {
                    // Open clicked tab and set tab as active
                    $(this).parent('li').addClass('active');
                    $(tabIdOpen).addClass('tabOpen');
                    // Close all other tabs and set tabs inactive
                    $(obj).find('a').each(function(){
                        var tabId = '#' + $(this).attr('rel');
                        // Close if not the opened tab
                        if (tabIdOpen != tabId) {
                            $(this).parent('li').removeClass('active');
                            $(tabId).removeClass('tabOpen');
                        }
                    });
                }
                // Clear href so page doesnt jump
                $(this).attr('href', ''); return false;
            });
        });
    });
}
