  
// Definition of class Folder 
// ***************************************************************** 

//imagepath = "../pcplus/dbgraphics/tocimages/"

//imagepath = "..cvd/store/tocimages/"
RegisterAr = new Array 
rEntries = 0 

d = document 
btmhtmlholder = 0

function lFolder(Description)
{ 
  // data 
  this.description = Description 
  this.id = -1   
  this.objThis = 0  
  this.iconImage = 0
  ////this.iconImageSrc = imagepath + "folderopen2.gif"   
  this.isOpen = true   
  this.children = new Array 
  this.nChildren = 0 
  //methods 
  this.initializeThis = initializeFolder 
  this.addChild = addChild 
  this.buildThis = buildFolder 
  this.showThis = showThis
  this.hideThis = hideThis
  this.toggleFolder = toggleFolder
  this.familyTree = familyTree
} 
function lLink(fullLink) // Constructor 
{ 
  //data 
  this.fullLink = fullLink
  this.id = -1 
  this.objThis = 0  
  ////this.iconImageSrc = imagepath +  "link.gif"
  // methods 
  this.initializeThis = initializeLink 
  this.buildThis = buildLink 
  this.showThis = showThis
  this.hideThis = hideThis
} 
 function createFld(description) 
{ 
  folder = new lFolder(description) 
  return folder 
} 
function createLnk(fullLink) 
{ 
  linkItem = new lLink(fullLink)   
  return linkItem 
} 
function insertFld(parentFolder, childFolder) 
{ 
  return parentFolder.addChild(childFolder) 
} 
function insertLnk(parentFolder, link) 
{ 
  parentFolder.addChild(link); 
} 
function addChild(node) 
{ 
  this.children[this.nChildren] = node
  this.nChildren++ 
  return node
}

function initializeDocument() 
{ 
  
  //if (d..getElementById) {
      browserVersion = 1 //IE4+   
  //} else{
  //    alert("IE4+  required")
  //    return;
  //} 
  foldersTree.initializeThis(0) 	
  foldersTree.showThis()
  d.getElementById("folder0").style.display = "none"
  //clickOnNode(0) //close it
  //clickOnNode(0) //open top children

} 
function initializeFolder(level) 
{ 
  var i=0  
  this.id = rEntries 
  RegisterAr[rEntries] = this 
  rEntries++  
 
  this.buildThis(level) 
   
  if (this.nChildren > 0) 
  { 
    level = level + 1 
    for (i=0 ; i < this.nChildren; i++)   
        this.children[i].initializeThis(level) 
  }

} 
function initializeLink(level) 
{  
  this.id = rEntries 
  RegisterAr[rEntries] = this 
  rEntries++   
 
  this.buildThis(level)   
} 
function helloWorld(ithis){
	alert(ithis);
}

function buildFolder(curlevel) 
{ 
  d.write("<table ") 
 
    d.write(" id='folder" + this.id + "' style='position:block;' ") 
  d.write(" border=0 cellspacing=0 cellpadding=0><tr><td  nowrap>") 
  d.write(getLineStart(curlevel) + "</td>")

  d.write("<td width=0 valign=center><a href='javascript:void(0)' onclick='clickOnNode("+this.id+")'><li CLASS='noexpand'>")
  /*d.write("<img name='folderIcon" + this.id + "' ") 
  d.write("src='" + this.iconImageSrc+"' border=0></a>") */
  d.write("</td><td valign=middle nowrap>") 


	d.write("<strong>") 
    d.write(this.description)
	d.write("</strong></td></tr></table>") 

	//d.write("<strong><a href='javascript:void(0)' onclick='clickOnNode("+this.id+")'>")  
    //d.write(this.description)
	//d.write("</a></strong></td></tr></table>") 
this.objThis = d.getElementById("folder"+this.id)
this.iconImage = d.getElementById("folderIcon"+this.id)

} 
function buildLink(curlevel) 
{   
  d.write("<table ") 

    d.write(" id='item" + this.id + "' style='position:block;' ") 
  d.write(" border=0 cellspacing=0 cellpadding=0><tr>") 
  d.write("<td nowrap>")
  d.write(getLineStart(curlevel) + "</td>")
  //d.write("<td width=0  valign=top><img src='" + imagepath + "link.gif' border=0></td>")
  d.write("<td width=0  valign=top><li></td>")
  d.write("<td>") 
  d.write(this.fullLink) 
  d.write("</td></tr></table>") 
   
this.objThis = d.getElementById("item"+this.id)
this.iconImage = d.getElementById("itemIcon"+this.id)

} 
function showThis() 
{ 
    this.objThis.style.display = "block" 
}  
function hideThis() 
{ 
    this.objThis.style.display = "none" 
   
  if (this.children){
	this.toggleFolder(false)
	}
} 
function clickOnNode(folderId) 
	{ 
	  isOpen = RegisterAr[folderId].isOpen
	  RegisterAr[folderId].toggleFolder(!isOpen) 
	}
function toggleFolder(val)
{
  if (val == this.isOpen)
	return
	
  var i=0;
 
  this.isOpen = !this.isOpen
 
  if ( this.isOpen ){
	////this.iconImage.src = imagepath + "folderopen2.gif"
	for (i=0; i<this.nChildren; i++) 
      this.children[i].showThis()
  }	else {
	////this.iconImage.src = imagepath + "folderopen2.gif"
	for (i=0; i<this.nChildren; i++) 
      this.children[i].hideThis()
 }
  // setTimeout("changeImage(" + this.iconImage + ",'folderclosedx.gif')",100)
} 


function getLineStart(level)
{
	linestart = ""
	for(l =1;l<level;l++)
		linestart = linestart + "&nbsp;&nbsp;"
	return linestart;
}	
function familyTree() 
{ 
  var i = 0 
  var n = this.nChildren 
  for (i=0; i < this.nChildren; i++){ 
    if (this.children[i].children) //is a folder 
      n = n + this.children[i].familyTree() 
  } 
  return n 
}



