// Functions called by the menu under the tree
// If you are not going to have an extra frame with action buttons, if your links
// are embedded in the documents that load in the right frame, for example,
// you should move these functions to the frameset file (in this case demoFuncs.html)
// If you are using a frameless layout, you will also have to move these functions
// to the appropriate page.
// In both cases: you will have to update the DOM paths used to access the functions
// and used by the functions themselves.

// 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 p04_expandTree(folderObj)
{
    var childObj;
    var i;

	//Open folder
    if (!folderObj.isOpen)
		p04_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
        p04_expandTree(childObj)
      }
    }

    try {redimensionarAlcadesBlocs();} catch(errorinfo) {}
}

// Close all folders
function p04_collapseTree()
{
	//hide all folders
	p04_clickOnNodeObj(p04_foldersTree)
	//restore first level
	p04_clickOnNodeObj(p04_foldersTree)

	try {redimensionarAlcadesBlocs();} catch(errorinfo) {}
}


// 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 p04_openFolderInTree(linkID) 
{
	var folderObj;
	folderObj = p04_findObj(linkID);
	folderObj.p04_forceOpeningOfAncestorFolders();
	if (!folderObj.isOpen)
		p04_clickOnNodeObj(folderObj);
} 

// Load a page as if a node on the tree was clicked (synchronize frames)
// (Highlights selection if highlight is available.)
function p04_loadSynchPage(linkID) 
{
	var folderObj;
	docObj = p04_findObj(linkID);
	docObj.p04_forceOpeningOfAncestorFolders();
	p04_foldersTree.p04_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 (document.body != "undefined") //scroll doesn work with NS4, for example
        document.body.scrollTop=docObj.navObj.offsetTop
} 
