// Open all folders
// May not work with very large trees (browser may time out)
// You may call this on a node other than the root, but it must be a folder
function expandTree(folderObj)
{
    var childObj;
    var i;

    //Open folder
    if (!folderObj.isOpen)
      parent.clickOnNodeObj(folderObj)

    //Call this function for all folder children
    for (i=0 ; i < folderObj.nChildren; i++)  {
      childObj = folderObj.children[i]
      if (typeof childObj.setState != "undefined") {//is folder
        expandTree(childObj)
      }
    }
}

// Close all folders
function collapseTree()
{
        //hide all folders
//        parent.treeframe.clickOnNodeObj(parent.treeframe.foldersTree)
        parent.clickOnNodeObj(parent.foldersTree)
        //restore first level
//        parent.treeframe.clickOnNodeObj(parent.treeframe.foldersTree)
        parent.clickOnNodeObj(parent.foldersTree)
}

// In order to show a folder, open all the folders that are higher in the hierarchy
// all the way to the root must also be opened.
// (Does not affect selection highlight.)
function openFolderInTree(linkID)
{
        var folderObj;
        folderObj = parent.findObj(linkID);
        folderObj.forceOpeningOfAncestorFolders();
        if (!folderObj.isOpen)
                parent.clickOnNodeObj(folderObj);
}

// Load a page as if a node on the tree was clicked (synchronize frames)
// (Highlights selection if highlight is available.)
function loadSynchPage(linkID)
{
        var folderObj;
        docObj = parent.findObj(linkID);
        docObj.forceOpeningOfAncestorFolders();
        parent.clickOnLink(linkID,docObj.link,'basefrm');

    //Scroll the tree window to show the selected node
    //Other code in these functions needs to be changed to work with
    //frameless pages, but this code should, I think, simply be removed
    if (typeof parent.document.body != "undefined") //scroll doesn work with NS4, for example
        parent.document.body.scrollTop=docObj.navObj.offsetTop
}

