<!--

You are free to copy the "Folder-Tree" script as long as you keep this copyright notice:

   * 
   * Script found in: http://www.geocities.com/Paris/LeftBank/2178/
   *
   * Author: Marcelino Alves Martins (martins@hks.com) January '97.
   *
   * Improvements submitted by other developers:
   *   Jun '97, Davespeed: code trimming, links enhanced
   *                         http://members.tripod.com/~davespeed   
   *   Jun '97, Bartje: converting the GIF's to transparent GIF89a
   *                         bartje@stad.dsl.nl
   *   Jul '97, Jason: contributed to support mixed folders (sub-folders and documents)
   *                         jgillis@libweb.uoregon.edu
   *   Oct '97, Joe Vitosky: optimized gifs with 16 colors instead of 256
   *                         gumbotronix@hotmail.com
   *

For instructions and other information refer to http://www.geocities.com/Paris/LeftBank/2178/foldertree.html

-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
  <HEAD>
[TITLE]

<SCRIPT language="JavaScript" type="text/javascript">

<!--  to hide script contents from old browsers

//each node in the tree is an Array with 4+n positions 
//  node[0] is 0/1 when the node is closed/open
//  node[1] is 0/1 when the folder is closed/open
//  node[2] number of children that are documents
//  node[3] is the name of the folder
//  node[4]...node[4+n] are the n children nodes

// ***************
// Building the data in the tree

[TREE]

// Auxiliary function to build the node
function gFld(name)
{
var arrayAux

  arrayAux = new Array
  arrayAux[0] = 0
  arrayAux[1] = 0
  arrayAux[2] = 0
  arrayAux[3] = name
  
  return arrayAux
}


//Append Child of type Folder
function insFld(parent, child)
{
  parent[parent.length] = child
  return child
}

//Append Child of type Doc
function insDoc(parent, child)
{
  parent[2] = parent[2] + 1
  parent[parent.length] = child
  return child
}


//these are the last entries in the hierarchy, the local and remote links to html documents (gLnk=generateLinkEntry)
function gLnk(icon, docDescription, link)
{
  if (USETEXTLINKS)
    return daveLnk(icon, docDescription, link)

  var retString =""

  if (icon==0)
  {
    retString = "<A href='"+link+"' target=folderFrame><img src='doc.gif' alt='Opens in right frame'"
  }
  else
  {
    if (icon==1)
       retString = "<A href='http://"+link+"' target=_blank><img src='link.gif' alt='Opens in new window'"
    else
       retString = "<A href='http://"+link+"' target=folderFrame><img src='link.gif' alt='Opens in right frame'"
  }

  retString = retString + " border=0><\/a><td nowrap><font size=-1 face='Arial, Helvetica'>" + docDescription + "<\/font>"

  return retString

}

// This function by davespeed
function daveLnk(icon, docDescription, link)
{
var retString =""
var l1=""
var l2="folderFrame"
var l3="doc"
var l4="right frame"

        if (icon!=0) {
                l1="http://"
                l2="_blank"
                l3="link"
                l4="new window"
                }
        if (icon==2) {
                l2="folderFrame"
                l4="right frame"
                }
        retString = "<A href='"+l1+link+"' target="+l2+"><img src='"+l3+".gif' alt='Opens in " +l4+ "' border=0><\/a><td nowrap><A href='"+l1+link+"' target="+l2+"><font size=-1 face='Arial, Helvetica'>" + docDescription + "<\/font><\/a>"

        return retString

}


// **********************
// display functions

//redraws the left frame
function redrawTree()
{
var doc = top.treeFrame.window.document

  doc.clear()
  doc.write("<body bgcolor='white'>\n")     
  redrawNode(foldersTree, doc, 0, 1, "")
  doc.close()
}

//recursive function over the tree structure called by redrawTree
function redrawNode(foldersNode, doc, level, lastNode, leftSide)
{
var j=0
var i=0
var numberOfFolders
var numberOfDocs

  doc.write("<table border=0 cellspacing=0 cellpadding=0>\n")
  doc.write("<tr>\n<td valign = middle nowrap>\n")

  doc.write(leftSide)

  if (level>0)
    if (lastNode) //the last 'brother' in the children array
    {
      doc.write("<img src='lastnode.gif' width=16 height=22>")
      leftSide = leftSide + "<img src='blank.gif' width=16 height=22>" 
    }
    else
    {
      doc.write("<img src='node.gif' width=16 height=22>")
      leftSide = leftSide + "<img src='vertline.gif' width=16 height=22>"
    }

  displayIconAndLabel(foldersNode, doc)
  doc.write("<\/table>\n\n")

  if (foldersNode.length > 4 && foldersNode[0]) //there are sub-nodes and the folder is open
  {
      numberOfFolders = foldersNode.length - 4 - foldersNode[2]

      // display the folders
      level = level + 1
      for (i=4 ; i < 4 + numberOfFolders; i++) 
      {
          if (i == (foldersNode.length - 1))
              redrawNode(foldersNode[i], doc, level, 1, leftSide)
          else
              redrawNode(foldersNode[i], doc, level, 0, leftSide)
      }
      // display the documents
      for ( i = 4 + numberOfFolders; i < foldersNode.length ; i++ ) 
      {
          doc.write("<table border=0 cellspacing=0 cellpadding=0 valign=middle>")
          doc.write("<tr><td nowrap>")
          doc.write(leftSide)
          if (i == foldersNode.length - 1)
              doc.write("<img src='lastnode.gif' width=16 height=22>")
          else
              doc.write("<img src='node.gif' width=16 height=22>")
          doc.write("<\/td><td>")
          doc.write(foldersNode[i])
          doc.write("<\/tr>")
          doc.write("<\/table>")
      }
  }
}

//builds the html code to display a folder and its label
function displayIconAndLabel(foldersNode, doc)
{
  doc.write("<A href='javascript:top.openBranch(\"" + foldersNode[3] + "\")'")
  if (foldersNode[1])
  {
    doc.write(" onMouseOver=\'window.status=\"Close folder\"; return true\'><img src=")
    doc.write("openfold.gif width=24 height=22 border=noborder><\/a>")
  }
  else
  {
    doc.write("onMouseOver='window.status=\"Open folder\"; return true'><img src=")
    doc.write("closedfo.gif width=24 height=22 border=noborder><\/a>")
  }
  doc.write("<td valign=middle align=left nowrap>")
  doc.write("<font size=-1 face='Arial, Helvetica'>"+foldersNode[3]+"<\/font>")
}

//**********************
// Recursive functions

//when a parent is closed all children also are
function closeFolders(foldersNode)
{
var i=0

    for (i=4; i< foldersNode.length - foldersNode[2]; i++)
      closeFolders(foldersNode[i])

    foldersNode[0] = 0
    foldersNode[1] = 0
}

//recursive over the tree structure
//called by openbranch
function clickOnFolderRec(foldersNode, folderName)
{
var i=0

  if (foldersNode[3] == folderName)
  {
    if (foldersNode[0])
      closeFolders(foldersNode)
    else
    {
      foldersNode[0] = 1
      foldersNode[1] = 1
    }
  }
  else
  {
      for (i = 4 ; i < foldersNode.length  - foldersNode[2]; i++)
         clickOnFolderRec(foldersNode[i], folderName)
  }
}


// ********************
// Event handlers

//called when the user clicks on a folder
function openBranch(branchName)
{
  clickOnFolderRec(foldersTree, branchName)
  if (branchName==foldersTree[3] && foldersTree[0]==0)
    top.folderFrame.location="basefold.htm" //closing the root folder
                                              //makes the welcome page to show
  timeOutId = setTimeout("redrawTree()",100)
}

//called after this html file is loaded
function initializeTree()
{
  generateTree()
  redrawTree()
}

var foldersTree = 0
var timeOutId = 0
var USETEXTLINKS = 0
generateTree() //sometimes when the user reloads the document Netscape 3.01 does not trigger the onLoad event (!!)


// end hiding contents from old browsers  -->

</SCRIPT>
  </HEAD>
  <FRAMESET cols="200,*" onload='initializeTree()'>
    <FRAME src="basetree.htm" name="treeFrame">
    <FRAME src="basefold.htm" name="folderFrame">

  </FRAMESET>
</HTML>