﻿$(document).ready(function() {
    HideNonExpandedChildren();
    ShowExpandedChildren();
    ToggleCollapseState();
});

function HideNonExpandedChildren() {
    $(".expandable ul").hide();
}

function ShowExpandedChildren() {
    $(".collapsable").children().each(function() {
        $(this).show();
    });
}

function ToggleCollapseState() {

    $('a.treeMinus').live("click", function(e) {
        var triggertext = "Expand " + $(this).siblings(".pagelink").text();
        $(this).text(triggertext).removeClass("treeMinus").addClass("treePlus").parent().children("ul").hide();
        e.preventDefault();
    });


    $('a.treePlus').live("click", function(e) {
        var triggertext = "Collapse " + $(this).siblings(".pagelink").text();
        $(this).text(triggertext).removeClass("treePlus").addClass("treeMinus").parent().children("ul").show();
        e.preventDefault();
    });

}
