function create_tabgroup(tabgroupTable, buttons)
{
    var tabgroupButtons = $(tabgroupTable).find(">tbody:first>tr:first>td:first").addClass("tabgroupButtons").html("");
    var tabgroupRows = $(tabgroupTable).find(">tbody:nth-child(2)>tr:not(:first):not(:last)").hide();

    $(tabgroupTable).find(">tbody:first>tr:first").after("<tr><td class='tcat' colspan='5' style='text-align:center'></td>");
    var tabgroupDescription = $(tabgroupTable).find(">tbody:first>tr:nth-child(2)>td:first");
    
    var tabButtonWidth = Math.floor(100.0 / $(buttons).length);
    var buttonsLength = $(buttons).length;
    $(buttons).each(function(i, buttonData){
        var tabButton = $("<div class='tabgroupButton'></div>").css("width", tabButtonWidth + "%").html("<div class='wrapper'>" + buttonData["title"] + "<img src='" + buttonData["image"] + "' /></div>").click(function(){
            $(tabgroupButtons).find(".tabgroupButton").removeClass("active");
            $(tabgroupRows).hide();

            $(this).addClass("active");
            $(buttonData["forumIds"]).each(function(i, forumId){
                $("#fr" + forumId).show();
            });

            $(tabgroupDescription).html(buttonData["tcat"]);
        });
        $(tabgroupButtons).append(tabButton);
    });
    $(tabgroupButtons).find(".tabgroupButton:first").addClass("first").trigger("click");
    $(tabgroupButtons).find(".tabgroupButton:last").addClass("last").css("width", (100 - (buttonsLength - 1) * tabButtonWidth) + "%");
}

