var lastcontrol;
function collapse_category(controller_id, control_id)
{
    var controller=document.getElementById(controller_id);
    var control=document.getElementById(control_id);

    if (control && controller) {
        controller.linked = control;
        control.style.display = "none";

        controller.onclick = function () {
            if (lastcontrol && lastcontrol != this) {
                lastcontrol.linked.style.display = 'none';
                lastcontrol.className =
                        "cdirectory-category-title";
            }

            if (this.linked.style.display == 'none') {
                this.linked.style.display = 'block';
                lastcontrol = this;
                this.className =
                        "cdirectory-category-title" +
                        " cdirectory-category-title-selected";
            } else {
                this.linked.style.display = 'none';
                lastcontrol.className =
                        "cdirectory-category-title";
            }
        };
    }
}
