function show_botlist(listptr, botid, expand)
{
    if ((expand == "expand" && listptr.css("display") != "none")
        || (expand == "collapse" && listptr.css("display") == "none"))
        return;

    if (!listptr.data("loaded"))
    listptr.html("<div class=\"padded\">Loading...</div>");

    if (expand == "expand")
    {
        listptr.show("fast");
    }
    else if (expand == "collapse")
    {
        listptr.hide("fast");
        return;
    }
    else
    {
        listptr.toggle("fast");
    }

    if (listptr.data("loaded") == true)
        return;

    listptr.load("rpc.php", { "request": "botlist", "id": botid });
    listptr.data("loaded", true);
}

function show_botlist_all(expand)
{
    var bots = $('.bots .bot');
    for (var i = 0; i < bots.length; i++)
    {
        show_botlist($(bots[i]).children('.list'), $(bots[i]).children('.botid').attr('title'), expand);
        var b = $(bots[i]).find('.expand a');
        if (expand == "expand")
            b.html("-");
        else if (expand == "collapse")
            b.html("+");
        else
            b.html(b.html() == "+" ? "-" : "+");
    }
}

function toggle_botlist(obj, botid)
{
    show_botlist($(obj).parent().parent().children('.list'), botid);
    obj.innerHTML = obj.innerHTML == '+' ? '-' : '+';
}
