 

//**************************************************************** 
// 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) December '97. 
//**************************************************************** 
 
//Log of changes: 
//       17 Feb 98 - Fix initialization flashing problem with Netscape
//       
//       27 Jan 98 - Root folder starts open; support for USETEXTLINKS; 
//                   make the ftien4 a js file 
//       10 May 2006 - The style display:block on table elements does not
//		       render properly in Firefox.  Commented out in
//		       display() function.
 
 
 
// Global variables 
// **************** 

//These two variables set the height and width of the icon images used in the side menu and site map
var tWidth = 1
var tHeight = 21

USETEXTLINKS = 1 
indexOfEntries = new Array 
menuNames = new Array
menuNumber = new Array
tagNumber = 0
nLevels = 0
nEntries = 0 
doc = document 
browserVersion = 0 
selectedFolder = 0
openedNode = -1
var imgPath = template_path + "/en/invest/grp/gs/library.nsf/";
var count = 0
var defaultYPos = 115
var yPosition = 10
 
 
 
// Definition of class Folder 
// ***************************************************************** 
 
function Folder(target, closed, opened, folderDescription, hreference,css) //constructor 
{ 
  //constant data 
  this.desc = folderDescription 
  this.hreference = hreference 
  this.target = target
  this.opened = imgPath + opened
  this.closed = imgPath + closed
  this.id = -1   
  this.navObj = 0  
  this.iconImg = 0  
  this.nodeImg = 0  
  this.isLastNode = 0 
  this.level = -1
  this.parentId = -1
  this.css=css

  //dynamic data 
  this.isOpen = true 
  //this.iconSrc = "ftv2folderopen.gif"   
  this.children = new Array 
  this.nChildren = 0 
 
  //methods 
  this.initialize = initializeFolder 
  this.setState = setStateFolder 
  this.addChild = addChild 
  this.createIndex = createEntryIndex 
  this.hide = hideFolder 
  this.display = display 
  this.renderOb = drawFolder 
  this.totalHeight = totalHeight 
  this.subEntries = folderSubEntries 
  this.outputLink = outputFolderLink 
} 
 
function setStateFolder(isOpen) 
{ 
  var subEntries 
  var totalHeight 
  var fIt = 0 
  var i=0 
 
  if (isOpen == this.isOpen) 
    return 
 
  if (browserVersion == 2)  
  { 
    totalHeight = 0 
    for (i=0; i < this.nChildren; i++) 
      totalHeight = totalHeight + this.children[i].navObj.clip.height 
      subEntries = this.subEntries() 
    if (this.isOpen) 
      totalHeight = 0 - totalHeight 
    for (fIt = this.id + subEntries + 1; fIt < nEntries; fIt++) 
      indexOfEntries[fIt].navObj.moveBy(0, totalHeight) 
  }  
  this.isOpen = isOpen 
  propagateChangesInState(this) 
} 
 
function propagateChangesInState(folder) 
{   
  var i=0 
 
  if (folder.isOpen) 
  { 
    if (folder.nodeImg) 
      if (folder.isLastNode) 
        folder.nodeImg.src = folder.opened 
      else 
	  folder.nodeImg.src = folder.opened 
	  //folder.iconImg.src = "ftv2folderopen.gif" 
    for (i=0; i<folder.nChildren; i++) 
      folder.children[i].display() 
  } 
  else 
  { 
    if (folder.nodeImg) 
      if (folder.isLastNode) 
        folder.nodeImg.src = folder.closed 
      else 
	  folder.nodeImg.src = folder.closed 
   	  //folder.iconImg.src = "ftv2folderclosed.gif" 
    for (i=0; i<folder.nChildren; i++) 
      folder.children[i].hide() 
  }  
} 
 
function hideFolder() 
{ 
  if ((browserVersion == 1)||(browserVersion ==3 )) { 
    if (this.navObj.style.display == "none") 
      return 
    this.navObj.style.display = "none" 
  } else { 
    if (this.navObj.visibility == "hidden") 
      return 
    this.navObj.visibility = "hidden" 
  } 
   
  this.setState(0) 
} 
 
function initializeFolder(level, lastNode, leftSide) 
{ 
var j=0 
var i=0 
var numberOfFolders 
var numberOfDocs 
var nc 
var img = this.closed

  indexOfEntries[nEntries] = this 
  nc = this.nChildren
      
  this.createIndex() 
  this.level = level  
  
  //storing the menu items tag number in an array indexed by the menu name
  menuNames[this.desc] = this.id
  
  //storing the menu items tag number in an array indexed by a number
  menuNumber[count] = this.id
  count = count + 1
  
  var auxEv = "" 

  if (browserVersion > 0) 
    auxEv = "<a class='"+this.css+"'>" 
  else 
    auxEv = "<a class='"+this.css+"'>" 
 
  if (level>1) 
  {
    if (lastNode) //the last 'brother' in the children array 
    { 
      this.renderOb(leftSide + auxEv + "<img src='" + imgPath + "pixelwedge.gif' width='" + tWidth + "' height='" + tHeight + "' border=0>" +"<img id='nodeIcon" + this.id + "' name='nodeIcon" + this.id + "' src="+img+" width='" + tWidth + "' height='" + tHeight + "' border=0></a>") 
      leftSide = leftSide + "<img src='" + imgPath + "pixelwedge.gif' width='" + tWidth + "' height='" + tHeight + "'>"  
      this.isLastNode = 1
    } 
    else 
    { 
	  this.renderOb(leftSide + auxEv + "<img src='" + imgPath + "pixelwedge.gif' width='" + tWidth + "' height='" + tHeight + "' border=0>" +"<img id='nodeIcon" + this.id + "' name='nodeIcon" + this.id + "' src='"+img+"' width='" + tWidth + "' height='" + tHeight + "' border=0></a>") 
      leftSide = leftSide + "<img src='" + imgPath + "pixelwedge.gif' width='" + tWidth + "' height='" + tHeight + "'>" 
      this.isLastNode = 0
    } 
  }
  else if (level == 1) 
  {
    if (lastNode) //the last 'brother' in the children array 
    { 
      this.renderOb(leftSide + auxEv + "<img id='nodeIcon" + this.id + "' name='nodeIcon" + this.id + "' src="+img+" width='" + tWidth + "' height='" + tHeight + "' border=0></a>") 
      this.isLastNode = 1 
    } 
    else 
    { 
      this.renderOb(leftSide + auxEv + "<img id='nodeIcon" + this.id + "' name='nodeIcon" + this.id + "' src='"+img+"' width='" + tWidth + "' height='" + tHeight + "' border=0></a>") 
      this.isLastNode = 0 
    } 
  }
  else
  {
     this.renderOb("") 
  } 
  
  if (nc > 0) 
  { 
    level = level + 1 
    for (i=0 ; i < this.nChildren; i++)  
    { 
      if (i == this.nChildren-1) 
	  {
        this.children[i].initialize(level, 1, leftSide) 
      }
	  else 
      {
	    this.children[i].initialize(level, 0, leftSide) 
	  }		
	 this.children[i].parentId = this.id
     } 
  } 
} 
 
function drawFolder(leftSide) 
{ 

  if (browserVersion == 2) { 
    if (!doc.yPos)
	{doc.yPos=defaultYPos;
		if (noshift){doc.yPos=yPosition;}else{doc.yPos=defaultYPos;}
	}
	doc.xPos=15
    doc.write("<layer id='folder" + this.id + "' left=" + doc.xPos + " top=" + doc.yPos + " visibility=hidden>") 
  } 
   
  doc.write("<table ") 
  if ((browserVersion == 1)||(browserVersion ==3 )) 
  	doc.write(" id='folder" + this.id + "' style='position:block;' ") 
  doc.write(" border=0 height=16 cellspacing=0 cellpadding=0>") 
  //alert("+" + leftSide + "+") ;
 if (!(this.desc=="" || this.desc=="Your Plan" || this.desc == "Votre Régime")){ 
  	doc.write("<tr><td colspan=1>&nbsp;</td></tr><tr><!--td valign=bottom>") 
  	//doc.write(leftSide) 
  	//this.outputLink() 
  	
  	doc.write("</td--><td background=button.gif valign=top class='"+this.css+"' >") 
  	if (USETEXTLINKS) 
  	{ 
    		this.outputLink() 
   		doc.write("&nbsp;<img width='1' height='22' src='" + imgPath + "cleargif.gif' border='0' alt='' align=absmiddle>" + this.desc + "</a>") 
   		//doc.write("&nbsp;" + this.desc + "</a>") 
  	} 
  	else 
  	{
    		doc.write("&nbsp;<img width='1' height='22' src='" + imgPath + "cleargif.gif' border='0' alt='' align=absmiddle>" + this.desc) 
    		//doc.write("&nbsp;" + this.desc) 
  	}
  	doc.write("</td></tr>")
  }
  doc.write("</table>") 
  
   
  if (browserVersion == 2) { 
    doc.write("</layer>") 
  } 
 
  if (browserVersion == 1) { 
    this.navObj = doc.all["folder"+this.id] 
    this.nodeImg = doc.all["nodeIcon"+this.id] 
  } else if (browserVersion == 2) { 
    this.navObj = doc.layers["folder"+this.id] 
    this.nodeImg = this.navObj.document.images["nodeIcon"+this.id] 
    doc.yPos=doc.yPos+this.navObj.clip.height 
  }
   else if(browserVersion == 3){
  		this.navObj = eval('document.getElementById("folder' + this.id + '")');
   		this.nodeImg = eval('document.getElementById("nodeIcon' + this.id + '")');
  
 }
} 
 
function outputFolderLink() 
{ 
  if (this.hreference) 
  { 
    doc.write("<a class='"+this.css+"' href='" + this.hreference + "' target='" + this.target + "' ") 
     //if (browserVersion > 0) 
     // doc.write("onClick='javascript:clickOnFolder("+this.id+")'") 
    doc.write(">") 
  } 
  else 
    doc.write("<a class='"+this.css+"'>") 
	//doc.write("<a href='javascript:clickOnFolder("+this.id+")'>")   
} 
 
function addChild(childNode) 
{ 
  this.children[this.nChildren] = childNode
  this.nChildren++ 
  return childNode 
} 
 

function folderSubEntries() 
{ 
  var i = 0 
  var se = this.nChildren 
 
  for (i=0; i < this.nChildren; i++){ 
    if (this.children[i].children) //is a folder 
      se = se + this.children[i].subEntries() 
  } 
  return se 
} 
 
 
// Definition of class Item (a document or link inside a Folder) 
// ************************************************************* 
 
function Item(icon, itemDescription, itemLink) // Constructor 
{ 
  // constant data 
  this.desc = itemDescription 
  this.link = itemLink 
  this.id = -1 //initialized in initalize() 
  this.navObj = 0 //initialized in render() 
  //this.iconImg = 0 //initialized in render() 
  if (icon == "")
  	this.iconSrc = "none"
  else
  	this.iconSrc = imgPath + icon
 
  // methods 
  this.initialize = initializeItem 
  this.createIndex = createEntryIndex 
  this.hide = hideItem 
  this.display = display 
  this.renderOb = drawItem 
  this.totalHeight = totalHeight 
} 
 
function hideItem() 
{ 
  if((browserVersion == 1)||(browserVersion == 3)) { 
    if (this.navObj.style.display == "none") 
      return 
    this.navObj.style.display = "none" 
//  }else if(browserVersion ==3 ){
	//ns6
  } else { 
    if (this.navObj.visibility == "hidden") 
      return 
    this.navObj.visibility = "hidden" 
  }     
} 
 
function initializeItem(level, lastNode, leftSide) 
{  
  this.createIndex() 
 
  if (level>0) 
    if (lastNode) //the last 'brother' in the children array 
    { 
      this.renderOb(leftSide + "<img src='" + imgPath + "pixelwedge.gif' width='" + tWidth + "' height='" + tHeight + "'>" )
	  leftSide = leftSide + "<img src='" + imgPath + "pixelwedge.gif' width='" + tWidth + "' height='" + tHeight + "'>"  
    } 
    else 
    { 
	  this.renderOb(leftSide + "<img src='" + imgPath + "pixelwedge.gif' width='" + tWidth + "' height='" + tHeight + "'>" ) 
      leftSide = leftSide + "<img src='" + imgPath + "pixelwedge.gif' width='" + tWidth + "' height='" + tHeight + "'>" 
    } 
  else 
    this.renderOb("")   
} 
 
function drawItem(leftSide) 
{ 
  if (browserVersion == 2) 
    doc.write("<layer id='item" + this.id +"' left=" + doc.xPos + " top=" + doc.yPos + " visibility=hidden>") 
     
  doc.write("<table ") 
  if ((browserVersion == 1)||(browserVersion==3)) 
    doc.write(" id='item" + this.id + "' style='position:block;' ") 
  doc.write(" border=0 height=16 cellspacing=0 cellpadding=0>") 
  doc.write("<tr><td width=2></td><td valign=top>") 
  doc.write(leftSide) 
  doc.write("<a href=" + this.link + ">") 
  
  if (this.iconSrc != "none")
  {
  	doc.write("<img id='itemIcon"+this.id+"' ") 
  	doc.write("src='"+this.iconSrc+"' border=0>") 
  }
  else
  	//doc.write("&nbsp;")
  
  doc.write("</a>") 
  doc.write("</td><td valign=middle >") 
  if (USETEXTLINKS) 
    doc.write("<a class='link' href="+this.link+" ><img width='1' height='1' src='" + imgPath + "cleargif.gif' border='0' alt=''>"+ this.desc+" </a>") 
  else 
    doc.write("<img width='1' height='1' src='" + imgPath + "cleargif.gif' border='0' alt=''>" + this.desc) 
  doc.write("</table>") 
   
  if (browserVersion == 2) 
    doc.write("</layer>") 
 
  if (browserVersion == 1) { 
    this.navObj = doc.all["item"+this.id] 
    //this.iconImg = doc.all["itemIcon"+this.id] 
  } else if (browserVersion == 2) { 
    this.navObj = doc.layers["item"+this.id] 
    //this.iconImg = this.navObj.document.images["itemIcon"+this.id] 
    doc.yPos=doc.yPos+this.navObj.clip.height 
  } else if(browserVersion == 3){
   		this.navObj = eval('document.getElementById("item'+this.id+'")'); 
  //document.getElementById('navObj').style.display = "block" ;
 	//this.navObj.style.display = "block"
	}
  
} 
 
 
// Methods common to both objects (pseudo-inheritance) 
// ******************************************************** 
 
function display() 
{ 
  if ((browserVersion == 1)||(browserVersion == 3)){
    // The below does not work correctly in Firefox 1.5.x
    //this.navObj.style.display = "block" 
    this.navObj.style.display = ""
  }
  else {
    this.navObj.visibility = "show" 
  }
} 
 
function createEntryIndex() 
{ 
  this.id = nEntries 
  indexOfEntries[nEntries] = this 
  nEntries++ 
} 
 
// total height of subEntries open 
function totalHeight() //used with browserVersion == 2 
{ 
  var h = this.navObj.clip.height 
  var i = 0 
   
  if (this.isOpen) //is a folder and _is_ open 
    for (i=0 ; i < this.nChildren; i++)  
      h = h + this.children[i].totalHeight() 
 
  return h 
} 
 
 
// Events 
// ********************************************************* 

//Below function was removed since folders are not used in this menu system
function clickOnFolder(folderId) 
{ 
 	var clicked = indexOfEntries[folderId] 
	if (!clicked.isOpen) 
 	  	openClose(folderId) 
	return  

 	if (clicked.isSelected) 
  		return 
} 
 
function clickOnNode(folderId) 
{ 
  var clickedFolder = 0 
  var prevClickedFolder = 0
  var state = 0 
	 
  clickedFolder = indexOfEntries[folderId] 
  state = clickedFolder.isOpen 

  clickedFolder.setState(!state) //open<->close  
} 

function openClose(folderId)
{
	var openFolder = 0 
	var prevOpenedFolder = 0
	var parent = -1	
	var prevParent = -1
	var level = 0
	var folderLevel = 0

  	openFolder = indexOfEntries[folderId] 
	parent = openFolder.parentId
	folderLevel = openFolder.level
	
	
	if (openedNode != -1)
	{
	prevOpenedFolder = indexOfEntries[openedNode] 
	prevParent = prevOpenedFolder.parentId
	level = prevOpenedFolder.level
	}
	
	if(openFolder.isOpen)
	{
		clickOnNode(folderId)
		if (parent == 0)
		{
			openedNode = -1
		}
		else
		{
			openedNode = parent
		}
	}
	else if (openedNode != -1)
	{
		if (parent == prevParent)
	  	{		
			clickOnNode(openedNode)
			clickOnNode(folderId)
			openedNode = folderId
		}
		else if (parent == openedNode)
		{
		clickOnNode(folderId)
		openedNode = folderId
		}
		else 
		{
			for (i=level ; i > 0; i--) 
 			{
				if (prevParent == parent)
				{
				clickOnNode(prevOpenedFolder.id)
				openedNode = -1
				break
				}
				prevOpenedFolder = indexOfEntries[prevOpenedFolder.parentId] 
				prevParent = prevOpenedFolder.parentId
 			}	
			clickOnNode(folderId)
			openedNode = folderId
 		}
	}
	else if (openedNode == -1)
	{
		if (folderLevel != 1)
		{
			for (i=1 ; i < folderLevel; i--) 
	 			{	
					if (parent != 0)	
					{									
						clickOnNode(parent)
						openFolder = indexOfEntries[openFolder.parentId] 
						parent = openFolder.parentId
					}
					else
					{
						break
					}
	 			}	
			clickOnNode(folderId)
			openedNode = folderId	
		}
		else
		{
			clickOnNode(folderId)
			openedNode = folderId	
		}
	}
}
 
function initializeDocument() 
{ 
  if (doc.all) 
    browserVersion = 1 //IE4   
  else if (doc.layers) 
      browserVersion = 2 //NS4 
 else if (NS5)   
 	  browserVersion = 3 //NS5    
    else 
      browserVersion = 0 //other 
  
  foldersTree.initialize(0, 1, "") 
  foldersTree.display()

  if (browserVersion > 0) 
  { 
   // doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>") 
	
    // close the whole tree 
    	clickOnNode(0) 
	// open the root folder 
    	clickOnNode(0) 
   }
 }
  
// Auxiliary Functions for Opening the menu at any submenu item
// ********************************************************* 
 function openMenuAt(expand)
 {
  if (browserVersion > 0) 
  { 
	tagNumber = menuNames[expand]
	if (tagNumber > 0)
	{
    openClose(tagNumber)
	}
  } 
} 

// Auxiliary Functions for Opening the menu at every submenu item
// ********************************************************* 
function openAll()
{
	var openFolder = 0 

 	if (browserVersion > 0) 
  	{ 
  		for (i=1 ; i < count; i++) 
		{	
			openFolder = indexOfEntries[menuNumber[i]]
			if (!(openFolder.isOpen))
			{								
				clickOnNode(menuNumber[i]) 
			}
		}	
  	} 
}  
 
// Auxiliary Functions for Folder-Treee backward compatibility 
// ********************************************************* 
 
function gFld(value, target, closed, opened, description, hreference,css) 
{ 
  folder = new Folder(target, closed, opened, description, hreference,css) 
  return folder 
} 
 
function gLnk(value, target, icon, description, linkData) 
{ 
  	fullLink = "" 
    
	if (target != "")
	{
		fullLink = "'"+linkData+"' target='"+target+"'" 
 	}
	else
	{
		fullLink = "'"+linkData+"'" 
	}
	
  linkItem = new Item(icon, description, fullLink)   
  return linkItem 
} 
 
function insFld(parentFolder, childFolder) 
{ 
  return parentFolder.addChild(childFolder) 
} 
 
function insDoc(parentFolder, document) 
{ 
  parentFolder.addChild(document) 
} 
 
//Dummy code used to ignore the site map extra links 
function insDocExtra(parentFolder, document) 
{ 
 	return true;
} 

function insFldExtra(parentFolder, childFolder) 
{ 
  return true;
} 

function gFldExtra(value, target, closed, opened, description, hreference) 
{ 
  return true;
} 
 
function gLnkExtra(value, target, icon, description, linkData) 
{ 
  return true; 
}

 

