/*
The SoftAd Group
Copyright (c) 2000-2004 The SoftAd Group, Inc.  All rights reserved
*/
// -------------------------------------------------------------------------------
// File name        : SoftAdTree.js
// -------------------------------------------------------------------------------
// Author           : Scott Pennington
// Original Authors : Joe Slovinski and Chad Peck
// Created on       : Tuesady, April 1, 2003
// 
// This file is a Generisized version of ftree_server.js that uses the DHTML DOM.
// 
// -------------------------------------------------------------------------------
// Last Updated     : 
// Updated by       : 
// -------------------------------------------------------------------------------
// Copyright © 2003 The SoftAd Group, Inc.


var L_TREE_PATH_LINE_WITH_CHILDREN_OPEN='Lminus.gif';
var L_TREE_PATH_LINE_WITH_CHILDREN_CLOSED='lplus.gif';
var L_TREE_PATH_LINE_NO_CHILDREN='L.gif';
var T_TREE_PATH_LINE_WITH_CHILDREN_OPEN='tminus.gif';
var T_TREE_PATH_LINE_WITH_CHILDREN_CLOSED='tplus.gif';
var T_TREE_PATH_LINE_NO_CHILDREN='t.gif';
//var BRANCH_TREE_WITH_CHILDREN_OPEN='openfoldericon.gif';
//var BRANCH_TREE_WITH_CHILDREN_CLOSED='foldericon.gif';
var BRANCH_TREE_WITH_CHILDREN_OPEN='icon_defaultfolderopen.gif';
var BRANCH_TREE_WITH_CHILDREN_CLOSED='icon_defaultfolderclosed.gif';
var BRANCH_TREE_NO_CHILDREN='foldericon.gif';
var ANCESTOR_TREE_PATH_LINE_WITH_CHILDREN='I.gif';
var ANCESTOR_TREE_PATH_LINE_NO_CHILDREN='white.gif';
var IMGPATH='/themes/default/en-us/common/admin/images/';
var F_PAGELOADED = 'TRUE';
var TRUE = 'TRUE';
var FALSE = 'FALSE';
var I_TREE_NOTE_KEY = 0;


function treeNode (id, name, image, isOpen, oTree) {
	this.key = I_TREE_NOTE_KEY++;
	this.id = id;
	this.name = name;
	this.image = image;
	this.isOpen = isOpen;
	this.children = new Array();
	this.parent=null;
	this.tree=oTree;
	this.hasChildren=treeNodeHaveChildren;
	this.isLeaf=treeNodeHaveChildren;
	this.childCount=treeNodeChildCount;
	this.removeChild=treeNodeRemoveChildNode;
	this.removeAllChildren=treeNodeRemoveAllChildren;
	this.openAll=treeNodeOpenAll;
	this.closeAll=treeNodeCloseAll;
	this.addChild=treeNodeAddChild;
	this.getChildByKey=treeNodeGetChildByKey;
	this.getChild=treeNodeGetChildByIndex;
	this.getIndex=treeNodeGetIndex;
	this.isLastChild=treeNodeIsLastChild;
	this.nodeImageOpen=BRANCH_TREE_WITH_CHILDREN_OPEN;
	this.nodeImageClosed=BRANCH_TREE_WITH_CHILDREN_CLOSED;
	this.nodeImageLeft = '';
	this.nodeImageActivate = TRUE;
	this.nodeValue = '';
	this.activate = TRUE;
	this.collapse=collapse;
	this.textStyle='';
	this.treeLevel = '';
}


function softAdTree (rootNodeName, rImage, rOpen, sTreeObjectName  ) {
	this.tree=new treeNode(0,rootNodeName,rImage,rOpen, this);
	this.selectedNode='';
	this.treeString='';
	this.treeHTML='';
	this.treeName=sTreeObjectName; //this is the name of the variable that holds the object instance.
	this.addTreeNode=addTreeNode;
	this.removeTreeNode=removeTreeNode;
	this.removeAllNodes=removeAllTreeNodes;
	this.makeTree=makeTree;
	this.refresh=refreshTree;
	this.render=renderTree;
	this.reset = resetTree;
	this.moveNode=moveTreeNode;
	this.selectNode=selectTreeNode;
	this.clickFunction='';
	this.dblClickFunction='';
	this.clickFullRowFunction='';
	this.openAll=openAll;
	this.closeAll=closeAll;
	this.getChild=getChild;
	this.clickOnNode=clickOnNode;	
	this.clickOnFolder=clickOnFolder;
	this.expandParents=expandParents;
	
}


function getChild(key) {
	var oNode = this.tree.getChildByKey(key);
	return oNode;	
}

function treeNodeGetChildByIndex(iIndex) {
	var oReturn = null;
	if (this.childCount()>iIndex) 
		oReturn = this.children[iIndex];
	return oReturn;
}

function treeNodeGetIndex(){
	var iReturn = -1;
	var iTest = this.key;
	var oNode = this.parent;
	if(oNode!=null){
		var iCount = oNode.childCount();
		for (var i=0;i<iCount;i++) {
			if (oNode.getChild(i).key==iTest){
				iReturn=i;
				break;
			}
		}
	}
	return iReturn;
}

function treeNodeIsLastChild() {
	var bReturn=false;
	var oNode = this.parent;
	if(oNode!=null){
		var iCount = oNode.childCount();
		var iIndex = this.getIndex();
		
		if (parseInt(iIndex)==parseInt(iCount-1)){
			bReturn=true;
		}
		//alert('parent='+oNode.name+' child='+this.name+' is at index='+iIndex+'total Children='+iCount+'is it last '+bReturn);
	}else{
		bReturn=true;
	}
	return bReturn;
}

function treeNodeGetChildByKey(key) {
	var oNode=null;
	var oTemp;
	if(this.key==key){
		oNode=this;
	}else{
		if (this.hasChildren()) {
			var iCount=this.childCount();
			for(var i=0;i<iCount;i++) {
				oTemp = this.getChild(i);
				oNode = oTemp.getChildByKey(key);
				if (oNode!=null)break;
			}
		}
	}
	return oNode;
}

function resetTree() {

}

function refreshTree() {
}

function renderTree() {
	//alert(this.display);
	document.write(this.display);
}

function addTreeNode(parent, key, name, image, open) {
	var oNode = this.getChild(parent);
	if (oNode!=null)
		return oNode.addChild(key,name,image,open);
	return
}

function treeNodeAddChild(key, name, image, open ) {
	var oNode = new treeNode(key,name,image,open, this.tree);
	oNode.parent = this;
	this.children.push(oNode);
	return oNode;
}

function removeTreeNode(key) {
	

}

function removeAllTreeNodes (){

}

function selectTreeNode ( ) {

}

function moveTreeNode ( ) {

}


function makeTree() {
	var aAncestorChildren =  new Array();
	this.display=makeNode(aAncestorChildren,this.tree);
	
}

function makeNode (aAncestorChildren, oTreeNode) {
	var sReturn='';
	var aWorkingAncestor;
	sReturn += makeNodeDiv(oTreeNode);
	sReturn += makeNodeStartTable(oTreeNode);
	sReturn += makeNodeAncestorCells(aAncestorChildren);
	sReturn += makeTreePathLine(oTreeNode);
	sReturn += makeBranch(oTreeNode);	 
	sReturn += makeBranchLabel(oTreeNode);
	sReturn += makeNodeEndTable();
	
	if(oTreeNode.hasChildren()){
		var bTrue
		if(oTreeNode.isLastChild())
			bTrue=false;
		else
			bTrue=true;
		aAncestorChildren.push(bTrue);	
		var iCount=oTreeNode.childCount();
		for(var i=0;i<iCount;i++){
			sReturn += makeNode(aAncestorChildren,oTreeNode.getChild(i));
		}
		aAncestorChildren.pop();
	}
	sReturn += closeNodeDiv();
	
	return sReturn;
}


function closeNodeDiv() {
	return '</div>';
}

function makeBranch(oTreeNode) {
	var sReturn='';
	var sImage='';
	var iKey = oTreeNode.key;
	var sIMG;
	var sImageId;
	if(oTreeNode.hasChildren()){
		sImageId='id="f'+iKey+'folder_img"';
		if(oTreeNode.isOpen=='yes'){
			sImage=oTreeNode.nodeImageOpen;
		}else{
			sImage=oTreeNode.nodeImageClosed;
		}
	}else{
		sImage=oTreeNode.nodeImageClosed;
		sImageId='id="f'+iKey+'docimg"';
	}
	var sTreeObjectName = oTreeNode.tree.treeName;
	
	if(oTreeNode.nodeImageActivate == TRUE){
		if(oTreeNode.activate == TRUE){
			sReturn+='<td nowrap="nowrap" onmousedown="if(fLoadPage ==F_PAGELOADED ){{'+sTreeObjectName+'.clickOnFolder('+iKey+','+TRUE+');}}" onmouseover="if(fLoadPage ==F_PAGELOADED ){{boldText('+iKey+');}}" onmouseout="if(fLoadPage ==F_PAGELOADED ){{normalText('+iKey+');}}" style="CURSOR:hand" isOpen="'+oTreeNode.isOpen+'">';
		}
		else{
			sReturn+='<td nowrap="nowrap" onmousedown="if(fLoadPage ==F_PAGELOADED ){{'+sTreeObjectName+'.clickOnFolder('+iKey+','+FALSE+');}}" style="CURSOR:hand" isOpen="'+oTreeNode.isOpen+'">';
		}
	}
	else{
		sReturn+='<td nowrap="nowrap">';
	}
	sIMG='<img '+ sImageId + ' src="'+IMGPATH + sImage+ '" border="0"/>';
	var nodeImageLeft = oTreeNode.nodeImageLeft;
	if (oTreeNode.tree.clickFunction!=''){
		sReturn+= nodeImageLeft + '<a href="#" onclick="'+oTreeNode.tree.clickFunction+'('+iKey+')">'+sIMG+'</a></td>';
	}else{
		sReturn+= nodeImageLeft + sIMG+'</td>';
	}
	return sReturn;
	
}

function makeBranchLabel(oTreeNode) {
	var sReturn='';
	var sImage=oTreeNode.image;
	var iKey = oTreeNode.key;
	var sIMG='';
	var sDbl='';
	if(oTreeNode.activate == TRUE){
		sReturn+='<td class="folder" id="f'+iKey+'text" onmousedown="if(fLoadPage ==F_PAGELOADED ){{clickOnItem('+iKey+');}}" onmouseover="if(fLoadPage ==F_PAGELOADED ){{boldText('+iKey+');}}" onmouseout="if(fLoadPage ==F_PAGELOADED ){{normalText('+iKey+');}}" style="CURSOR:hand" noWrap width="100%">';
	}		
	else{
		var sTreeObjectName = oTreeNode.tree.treeName;
		sReturn+='<td class="folder" id="f'+iKey+'text" onmousedown="if(fLoadPage ==F_PAGELOADED ){{'+sTreeObjectName+'.clickOnFolder('+iKey+','+FALSE+');}}" style="CURSOR:hand" noWrap width="100%">';
	}
	if(sImage!='') {
		//sIMG='<img id="f'+iKey+'lblimg" height="20" src="'+IMGPATH + sImage+ '" width="19" border="0" alt="'+oTreeNode.name+'"/>';	
		sIMG='<img id="f'+iKey+'lblimg" src="'+IMGPATH + sImage+ '"border="0" alt="'+oTreeNode.name+'"/>';	
	}else{
		if (oTreeNode.textStyle!=''){
			sIMG = '<'+oTreeNode.textStyle+'>'+oTreeNode.name+'</'+oTreeNode.textStyle+'>';
		}else{
			sIMG=oTreeNode.name;
		}
	}
	if(oTreeNode.tree.dblClickFunction!=''){
		sDbl='ondblclick="' + oTreeNode.tree.dblClickFunction + '(' + iKey + ')"' ;
	}
	if (oTreeNode.tree.clickFunction!=''){
		sReturn+='<a class="folder" href="#" onclick="'+oTreeNode.tree.clickFunction + '('+iKey+')"';
		if (sDbl!=''){
			sReturn += sDbl;
		}
		sReturn += '>'+sIMG+'</a></td>';
	}else{
		if (sDbl!='') {
			sReturn+='<a class="folder" href="#" '+sDbl;
			sReturn += '>'+sIMG+'</a></td>';
		}else{
			sReturn+=sIMG+'</td>';
		}
	}
	return sReturn;
	
}


function makeTreePathLine(oTreeNode) {
	var sReturn='';
	var sImage='';
	var iKey = oTreeNode.key;
	if(oTreeNode.hasChildren()){
		if(oTreeNode.isLastChild()) {
			if(oTreeNode.isOpen=='yes'){
				sImage=L_TREE_PATH_LINE_WITH_CHILDREN_OPEN;
			}else{
				sImage=L_TREE_PATH_LINE_WITH_CHILDREN_CLOSED;
			}
		}else{
			if(oTreeNode.isOpen=='yes'){
				sImage=T_TREE_PATH_LINE_WITH_CHILDREN_OPEN;
			}else{
				sImage=T_TREE_PATH_LINE_WITH_CHILDREN_CLOSED;			
			}
		}
	}else{
		if(oTreeNode.isLastChild()) {
			sImage=L_TREE_PATH_LINE_NO_CHILDREN;
		}else{
			sImage=T_TREE_PATH_LINE_NO_CHILDREN;
		}	
	}
	var sTreeObjectName = oTreeNode.tree.treeName;
	if(oTreeNode.activate == TRUE){
		sReturn+='<td onmousedown="if(fLoadPage ==F_PAGELOADED ){{'+sTreeObjectName+'.clickOnNode('+iKey+');}}" onmouseover="if(fLoadPage ==F_PAGELOADED){{boldText('+iKey+');}}" onmouseout="if(fLoadPage ==F_PAGELOADED ){{normalText('+iKey+')}};" style="CURSOR:hand">';
	}
	else{
		sReturn+='<td onmousedown="if(fLoadPage ==F_PAGELOADED ){{'+sTreeObjectName+'.clickOnNode('+iKey+');}}" style="CURSOR:hand">';
	}
	sReturn+='<img id="f'+iKey+'nimg" src="'+IMGPATH + sImage+ '" border="0"/>';
	sReturn+='</td>';
	return sReturn;
}

function makeNodeStartTable (oTreeNode) {
	var sReturn = '<table id="f'+oTreeNode.key+'table" cellSpacing="0" cellPadding="0" width="100%" border="0" onclick="if(fLoadPage ==F_PAGELOADED ){{'+oTreeNode.tree.clickFullRowFunction + '('+oTreeNode.key+',this);}}">';
	var sTemp = "<div id='viewer' style='background-color:#cccccc;marginleft:0;visibility:visible;position:absolute;width:0;height:0;z-index:1;overflow:hidden'></div>";
	sReturn += '<tr >';
	return sReturn;
}

function makeNodeEndTable () {
	var sReturn = '</tr></table>';
	return sReturn;
}

function makeNodeDiv (oTreeNode) {
	var oParentNodeIsOpen = (oTreeNode.key != '0') ? oTreeNode.parent.isOpen: 'yes';	
	if(oTreeNode.isOpen == 'no' && oParentNodeIsOpen == 'no'){
		var sReturn='<div id="f' + oTreeNode.key + '"style="DISPLAY:none;POSITION:RELATIVE" isOpen="' + oTreeNode.isOpen + '">'; 
	}else{
		var sReturn='<div id="f' + oTreeNode.key + '"style="DISPLAY:block;POSITION:RELATIVE" isOpen="' + oTreeNode.isOpen + '">'; 
	}
	return sReturn;
}

function makeNodeAncestorCells(aAncestorChildren){
	var sReturn='';
	var sImage;
	var iCount=aAncestorChildren.length;
	for(var i=0;i<iCount;i++) {
		if(aAncestorChildren[i]){
			sImage = ANCESTOR_TREE_PATH_LINE_WITH_CHILDREN;
		}else{
			sImage = ANCESTOR_TREE_PATH_LINE_NO_CHILDREN;
		}
		sReturn += '<td><img src="'+IMGPATH + sImage + '"/></td>';
	}
	return sReturn

}




















function treeNodeParent(){
	return this.parent;
}



function treeNodeHaveChildren () {
	if (this.children.length)
		return true;	
	else
		return false;
 
}

function treeNodeChildCount() {
	return this.children.length
}

function treeNodeRemoveChildNode (oChild) {
	
}

function treeNodeRemoveAllChildren ( ) {
	this.children = new Array();
}

function treeNodeOpenAll ( ) {

}

function treeNodeCloseAll( ) {

}

function openAll ( ) {

}

function closeAll( ) {

}


//=================================================================================
//
//	Above are the Classes to Render the Tree and manage the backend.
//
//	Below are the functions used to manipulate the tree once it is rendered.
//
//
//=====================================================================================

//=====================================================================================
//The DIV is controls the Branch expand and collapse
//	the table is the actual display of the Tree
//		there is only one Row for this table
//			There are 3 main columns (cell/td) and (n) dynamic cell
//			cell 0+)	This is a dynamic cell.  This cell will be created for each level.  
//						For each ancestor that has children that are to appear below this node the cell
//						contains a line (I.gif).  If the ancestors has children below this node then a white space is 
//						used instead of the line to keep the indenting
//						
//
//
//
//			cell 1)	is the L/T/Minus/Plus and fires 3 events onmousedown=clickOnNode(key), onmouseout=normalText(key), and onmouseover=boldText(key) 
//			cell 2) is the icon for the branch or leaf and fires 3 events onmousedown=clickOnFolder(key), onmouseout=normalText(key), and onmouseover=boldText(key)
//					cell 2 also wraps the img with an anchor that fires an onclick event custom function passing the (key) to the function
//			cell 3)	displays the "text" or "Image" for the the branch or leaf and fires 3 events onmousedown=clickOnFolder(key), onmouseout=normalText(key), and onmouseover=boldText(key)
//					cell 3 also wraps the "text" or "Image" with an anchor anchor that fires an onclick event custom function passing the (key) to the function
//================================================================================================

// -------------------------------------------------------------------------------
// Function         : clickOnNode(id)
// -------------------------------------------------------------------------------
// Author           : Joe Slovinski
// Created on       : Friday, March 17, 2000
// 
// This function is called when the user click's on the + or - images of a node 
// on the tree.  It expands or collapses the specified folder.  This function 
// also toggles the folder images to the appropriate state.
// -------------------------------------------------------------------------------
// Parameters
// -------------------------------------------------------------------------------
// NAME         TYPE        DESCRIPTION
// id           integer     Integer used with nodeFromID look-up
// -------------------------------------------------------------------------------
// Last Updated     : 
// Updated by       : 
// -------------------------------------------------------------------------------

var selectedItem = 0;

var imgFolder = new Image();
imgFolder.src = IMGPATH+ BRANCH_TREE_WITH_CHILDREN_CLOSED;
var imgFolderOpen = new Image();
imgFolderOpen.src = IMGPATH + BRANCH_TREE_WITH_CHILDREN_OPEN;
var imgLMinus = new Image();
imgLMinus.src = IMGPATH + L_TREE_PATH_LINE_WITH_CHILDREN_OPEN;
var imgLPlus = new Image();
imgLPlus.src = IMGPATH + L_TREE_PATH_LINE_WITH_CHILDREN_CLOSED;
var imgTMinus = new Image();
imgTMinus.src = IMGPATH + T_TREE_PATH_LINE_WITH_CHILDREN_OPEN;
var imgTPlus = new Image();
imgTPlus.src = IMGPATH + T_TREE_PATH_LINE_WITH_CHILDREN_CLOSED;

// -------------------------------------------------------------------------------
// Function         : clickOnNode(id)
// -------------------------------------------------------------------------------
// Author           : Joe Slovinski
// Created on       : Friday, March 17, 2000
// 
// This function is called when the user click's on the + or - images of a node 
// on the tree.  It expands or collapses the specified folder.  This function 
// also toggles the folder images to the appropriate state.
// -------------------------------------------------------------------------------
// Parameters
// -------------------------------------------------------------------------------
// NAME         TYPE        DESCRIPTION
// id           integer     Integer used with nodeFromID look-up
// -------------------------------------------------------------------------------
// Last Updated     : 
// Updated by       : 
// -------------------------------------------------------------------------------

function clickOnNode(id)
{
  var clickedFolder
  var isOpen
  //alert(id);
  clickedFolder = document.getElementById('f' + id);
  isOpen = clickedFolder.getAttribute("isOpen");
  var oTreeNode = this.getChild(id);
  fClickEvent = false;
  childNodes = clickedFolder.children;

  if(childNodes.length > 1){ //If the the child Node has child Nodes
    switch(isOpen) {
      case "no":
        expand(id);
        clickedFolder.setAttribute("isOpen", "yes");
        if(clickedFolder.getAttribute("open_image") == null) document.all["f" + id + "folder_img"].src = IMGPATH + oTreeNode.nodeImageOpen;
        else document.all["f" + id + "folder_img"].src = IMGPATH + clickedFolder.attributes.getNamedItem("open_image").text;
        break;
      case "yes":
        oTreeNode.collapse(id);
        clickedFolder.setAttribute("isOpen", "no");
        if(clickedFolder.getAttribute("image") == null) document.all["f" + id + "folder_img"].src = IMGPATH + oTreeNode.nodeImageClosed;
        else document.all["f" + id + "folder_img"].src = IMGPATH + clickedFolder.attributes.getNamedItem("image").text;
  	break;
    }
  }
}

// -------------------------------------------------------------------------------
// Function         : clickOnFolder(id)
// -------------------------------------------------------------------------------
// Author           : Joe Slovinski
// Created on       : Friday, March 17, 2000
// 
// This function is called when the user click's on a folder image or the text of 
// a folder.  It expands the specified folder.  This function also toggles the 
// folders images to the appropriate state.
// -------------------------------------------------------------------------------
// Parameters
// -------------------------------------------------------------------------------
// NAME         TYPE        DESCRIPTION
// id           integer     Integer used with nodeFromID look-up
// -------------------------------------------------------------------------------
// Last Updated     : 
// Updated by       : 
// -------------------------------------------------------------------------------

function clickOnFolder(id,activate)
{
  var clickedFolder
  var isOpen
  
  clickedFolder = document.all["f" + id]
  isOpen = clickedFolder.getAttribute("isOpen")

  if(activate == TRUE){
    disable(id);
    document.all["f" + id + "table"].className = 'onClick';
    selectedItem = id;
   // activate(id)
  } 
  
  var oTreeNode = this.getChild(id);
  var childNodes = oTreeNode.children;
  if(childNodes.length > 0){
    switch(isOpen) {
      case "no":
        expand(id)
        clickedFolder.setAttribute("isOpen", "yes")
        if(clickedFolder.getAttribute("open_image") == null) document.all["f" + id + "folder_img"].src = IMGPATH+oTreeNode.nodeImageOpen;
        else document.all["f" + id + "folder_img"].src = IMGPATH + clickedFolder.attributes.getNamedItem("open_image").text
        break;
      case "yes":
        oTreeNode.collapse(id);
        clickedFolder.setAttribute("isOpen", "no");
        if(clickedFolder.getAttribute("image") == null) document.all["f" + id + "folder_img"].src = IMGPATH + oTreeNode.nodeImageClosed;
        else document.all["f" + id + "folder_img"].src = IMGPATH + clickedFolder.attributes.getNamedItem("image").text;
        break;
    }
  }
}

// -------------------------------------------------------------------------------
// Function         : clickOnItem(id)
// -------------------------------------------------------------------------------
// Author           : Joe Slovinski
// Created on       : Friday, March 17, 2000
// 
// This function is called when the user clicks on the icon or text of a item in 
// folder, it redirects the user to the URL specified by the url XML attribute.
// -------------------------------------------------------------------------------
// Parameters
// -------------------------------------------------------------------------------
// NAME         TYPE        DESCRIPTION
// id           integer     Integer used with nodeFromID look-up
// -------------------------------------------------------------------------------
// Last Updated     : 
// Updated by       : 
// -------------------------------------------------------------------------------

function clickOnItem(id)
{
  disable(id);
  activate(id)
}

// -------------------------------------------------------------------------------
// Function         : collapse(node)
// -------------------------------------------------------------------------------
// Author           : Joe Slovinski
// Created on       : Friday, March 17, 2000
// 
// This function is a helper function of the clickOnNode and clickOnFolder 
// functions.  It collapses the specified folder.
// -------------------------------------------------------------------------------
// Parameters
// -------------------------------------------------------------------------------
// NAME         TYPE        DESCRIPTION
// node         XMLDOMNode  node to collapse
// -------------------------------------------------------------------------------
// Last Updated     : 
// Updated by       : 
// -------------------------------------------------------------------------------

function collapse(id)
{
  var i
  var id_attribute
  var nodeImg

  node = document.getElementById('f' + id);
  nodeImg = document.getElementById('f' + id + 'nimg');
  childNodes = node.children
  siblings = node.parentElement.children
  
  if(siblings.length == 2 || siblings.item(siblings.length-1) == node) nodeImg.src = imgLPlus.src
  else nodeImg.src = imgTPlus.src
  //var sTemp = 'f'+id+'folder_img';
  //var oNode = document.getElementById(sTemp);
  document.getElementById('f'+id+'folder_img').src = this.nodeImageClosed;

  node.setAttribute("isOpen", "no")
  
  for(i=0; i < childNodes.length; i++)
  {
    if(childNodes.item(i).tagName.toUpperCase() == "DIV") {
      childNodes.item(i).style.display = 'none'
      //grandChildren = childNodes.item(i).children
      //if(grandChildren.length > 1) collapse(childNodes.item(i).id)
    }
  }
}

// -------------------------------------------------------------------------------
// Function         : expand(id)
// -------------------------------------------------------------------------------
// Author           : Joe Slovinski
// Created on       : Friday, March 17, 2000
// 
// This function is a helper function of the clickOnNode and clickOnFolder 
// functions.  It expands the specified folder.
// -------------------------------------------------------------------------------
// Parameters
// -------------------------------------------------------------------------------
// NAME         TYPE        DESCRIPTION
// id           integer     Integer used with nodeFromID look-up
// -------------------------------------------------------------------------------
// Last Updated     : 
// Updated by       : 
// -------------------------------------------------------------------------------

function expand(id)
{
  var node
  var i
  var nodeImg
      
  node = document.getElementById('f' + id);
  childNodes = node.children
  nodeImg = document.getElementById('f' + id + 'nimg');
  nodeText = document.getElementById('f' + id + 'text');
  siblings = node.parentNode.children
  
  if(siblings.length == 2 || siblings.item(siblings.length-1) == node) nodeImg.src = imgLMinus.src
  else nodeImg.src = imgTMinus.src

  for(i=0; i < childNodes.length; i++)
  {
    //if(childNodes.item(i).tagName.toUpperCase() == "DIV") {
	  childNodes.item(i).style.display = 'block'
    //}
  }
}
// -------------------------------------------------------------------------------
// Function         : expandParents(id)
// -------------------------------------------------------------------------------
// Author           : Chad Peck
// Created on       : Tuesday, January 9, 2001
// 
// This function is a helper function of the clickOnNode and clickOnFolder 
// functions.  It expands the specified folder.
// -------------------------------------------------------------------------------
// Parameters
// -------------------------------------------------------------------------------
// NAME         TYPE        DESCRIPTION
// id           integer     Integer used with nodeFromID look-up
// -------------------------------------------------------------------------------
// Last Updated     : 
// Updated by       : 
// -------------------------------------------------------------------------------

function expandParents(id)
{
  var node
  var parent
      
  node = document.all["f" + id];
  parent = node.parentNode
  
  while(parent.tagName.toUpperCase() == "DIV") {
	if(parent.getAttribute("isOpen") != 'yes') {
		this.clickOnNode(parent.id.substring(1,parent.id.length))
	}
	parent = parent.parentNode
  }
}

// -------------------------------------------------------------------------------
// Function         : boldText(id)
// -------------------------------------------------------------------------------
// Author           : Joe Slovinski
// Created on       : Friday, March 17, 2000
// 
// This function is placed on the ONMOUSEOVER events of all node images and text.  
// It bolds the text of the specified node.
// -------------------------------------------------------------------------------
// Parameters
// -------------------------------------------------------------------------------
// NAME         TYPE        DESCRIPTION
// id           integer     Integer used with nodeFromID look-up
// -------------------------------------------------------------------------------
// Last Updated     : 
// Updated by       : 
// -------------------------------------------------------------------------------

function boldText(id)
{
  document.getElementById("f" + id + "text").className = 'folderOver';  
}

// -------------------------------------------------------------------------------
// Function         : normalText(id)
// -------------------------------------------------------------------------------
// Author           : Joe Slovinski
// Created on       : Friday, March 17, 2000
// 
// This function is placed on the ONMOUSEOUT events of all node images and text.  
// It returns the text of the specified node to normal.
// -------------------------------------------------------------------------------
// Parameters
// -------------------------------------------------------------------------------
// NAME         TYPE        DESCRIPTION
// id           integer     Integer used with nodeFromID look-up
// -------------------------------------------------------------------------------
// Last Updated     : 
// Updated by       : 
// -------------------------------------------------------------------------------

function normalText(id)
{
  document.getElementById("f" + id + "text").className = 'folder';
}

function activate(id)
{
  document.getElementById("f" + id + "table").className = 'onClick';
  selectedItem = id;
}

function disable(id)
{
  if(selectedItem != id) {
    document.getElementById("f" + selectedItem + "table").className = 'normalBG';
  }
}

var fLoadPage='TRUE';
var fClickEvent = true;