<!-- Begin Hiding
var treehtml;
var tree;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// start() - GENERAL FUNCTION - called by the HTML document once loaded - starts OmenTree by
//					  first loading the user data, and then drawing the tree.


function start() {
	tree = 	document.getElementById('tree');
	structureStyle = 0;                   // 0 for light background, 1 for dark background
 	backgroundColor = '#FFFFFF';           // sets the bgColor of the menu
     	textColor = '#000000';           // sets the color of the text used in the menu
     	linkColor = '#0000AA';           // sets the color of any text links (usually defined in additional HTML sources)
     	aLinkColor = '#FF0000';           // sets the active link color (when you click on the link)
     	vLinkColor = '#880088';           // sets the visited link color
     	backgroundImage = ' ';                  // give the complete path to a gif or jpeg to use as a background image
     	defaultTargetFrame = 'main';      // the name of the frame that links will load into by default 
     	defaultImageURL = 'gfx/';        // the URL or path where the OmenTree images are located
     	defaultLinkIcon = 'img-page-globe.gif';  // the default icon image used for links
     	omenTreeFont = 'Arial CE,Helvetica';  // the font used for the menu
     	omenTreeFontSize = 1;                                // its size - don't make it too big!
     	prefixHTML = "";
     	suffixHTML = "";
     	treeoldopen = 0;
	loadData();
	drawTree();
	afterDraw();
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// drawTree() - GENERAL FUNCTION - starts the recursive tree drawing process by first writing
//					     the root node, and then all subordinate branches.

function layerwrite(strs){
  treehtml = treehtml + strs;
}

function getidpath(node)
{
   var nodepath;
   var currentIndex = 1;
   nodepath = "";
	while (currentIndex <= treeData.length) {
		if (treeData[currentIndex] == node) { nodepath = currentIndex; }
		currentIndex++} 
   return nodepath; 
}

function drawTree() {
treehtml = "";
   layerwrite("<FONT FACE='" + omenTreeFont + "' SIZE=" + omenTreeFontSize + " COLOR='" + textColor + "'>\n");
	layerwrite("\n<NOBR>\n");
	if (treeData[1].target == "") {var targetFrame = defaultTargetFrame} else {var targetFrame = treeData[1].target}
	if (treeData[1].icon == "")   {var imageString = defaultImageURL + 'img-globe-' + structureStyle + '.gif'} else {imageString = defaultImageURL + treeData[1].icon}

	layerwrite("<A class='treelink' HREF='openpage.asp?uid="+getidpath(1) +"&page=" + escape(treeData[1].url) + "' TARGET='" + targetFrame + "' onMouseOver=\"window.status='" + treeData[1].url + "'; return true\"><IMG SRC='" + imageString + "' WIDTH=16 HEIGHT=16 ALIGN=TEXTTOP BORDER=0 ALT='" + treeData[1].url + "'>&nbsp;<B>" + treeData[1].name + "</B><BR></A>\n");
	drawBranch("root","");
	layerwrite("</NOBR>\n");
	layerwrite("</FONT>");
               if (document.layers){
                 document.layers.tree.document.write(treehtml)
                 document.layers.tree.document.close()
               }
               else  { 
				 tree.innerHTML=treehtml;
			   }	
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// drawBranch() - GENERAL FUNCTION - used by the drawTree() function to recursively draw all
//						 visable nodes in the tree structure.

function drawBranch(startNode,structureString) {
	var children = extractChildrenOf(startNode);
	var currentIndex = 1;
	while (currentIndex <= children.length) {
		layerwrite(structureString);
		if (children[currentIndex].type == 'link') {
			if (children[currentIndex].icon == "") {
				var imageString = "img-point.gif";
			}
			else {var imageString = children[currentIndex].icon}
			if (children[currentIndex].target == "") {
				var targetFrame = defaultTargetFrame;
			}
			else {var targetFrame = children[currentIndex].target}
layerwrite("<A class='treelink' HREF='openpage.asp?puid="+getidpath(children[currentIndex]) +"&page=" +escape(children[currentIndex].url) + "' TARGET='" + targetFrame + "' onMouseOver=\"window.status='" + children[currentIndex].url + "'; return true;\">");
			if (currentIndex != children.length) {
				layerwrite("<IMG  border=\"0\"  SRC='" + defaultImageURL + imageString+"' WIDTH=16 HEIGHT=16 ALIGN=TEXTTOP>")
			}
			else {
				layerwrite("<IMG  border=\"0\" SRC='" + defaultImageURL +  imageString+"' WIDTH=16 HEIGHT=16 ALIGN=TEXTTOP>")
			}
			layerwrite("&nbsp;" + children[currentIndex].name + "<BR></A>\n")	
		}
		else {
			var newStructure = structureString;
		
			if (children[currentIndex].iconClosed == "") {var iconClosed = "img-minus.gif"} else {var iconClosed = children[currentIndex].iconClosed}
			if (children[currentIndex].iconOpen == "")   {var iconOpen = "img-plus.gif"} else {var iconOpen = children[currentIndex].iconOpen}
		
			if (currentIndex != children.length) {
				if (children[currentIndex].open == 0) {
					layerwrite("<A class='treelink' HREF=\"javascript:toggleFolder('" + children[currentIndex].id + "',1)\" onMouseOver=\"window.status='Click to open this folder'; return true\"><IMG SRC='" + defaultImageURL + iconOpen +"' WIDTH=16 HEIGHT=16 ALT='Click to open this folder' ALIGN=TEXTTOP BORDER=0>")
					layerwrite("&nbsp;" + children[currentIndex].name + "<BR></A>\n")
				}
				else {
					layerwrite("<A class='treelink' HREF=\"javascript:toggleFolder('" + children[currentIndex].id + "',0)\" onMouseOver=\"window.status='Click to close this folder'; return true\"><IMG SRC='" + defaultImageURL + iconClosed+"'  WIDTH=16 HEIGHT=16 ALT='Click to close this folder' ALIGN=TEXTTOP BORDER=0>");
					layerwrite("&nbsp;" + children[currentIndex].name + "<BR></A>\n");
					newStructure = newStructure + "<IMG SRC='" + defaultImageURL + "img-blank.gif' WIDTH=16 HEIGHT=16 ALIGN=TEXTTOP>";
					drawBranch(children[currentIndex].id,newStructure); 
				}
			}
			else {
				if (children[currentIndex].open == 0) {
					layerwrite("<A class='treelink' HREF=\"javascript:toggleFolder('" + children[currentIndex].id + "',1)\" onMouseOver=\"window.status='Click to open this folder'; return true\"><IMG SRC='" + defaultImageURL + iconOpen+"' WIDTH=16 HEIGHT=16 ALT='Click to open this folder' ALIGN=TEXTTOP BORDER=0>")
					layerwrite("&nbsp;" + children[currentIndex].name + "<BR></A>\n")
				}

				else {
					layerwrite("<A class='treelink' HREF=\"javascript:toggleFolder('" + children[currentIndex].id + "',0)\" onMouseOver=\"window.status='Click to close this folder'; return true\"><IMG SRC='" + defaultImageURL + iconClosed+"' WIDTH=16 HEIGHT=16 ALT='Click to close this folder' ALIGN=TEXTTOP BORDER=0>");
					layerwrite("&nbsp;" + children[currentIndex].name + "<BR></A>\n");
					newStructure = newStructure + "<IMG SRC='" + defaultImageURL + "img-blank.gif' WIDTH=16 HEIGHT=16 ALIGN=TEXTTOP>";
					drawBranch(children[currentIndex].id,newStructure); 
				}
			}
		}
		currentIndex++;
	}
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// toggleFolder() - GENERAL FUNCTION - opens/closes folder nodes.
function toggleFolder(id,status) {
	var nodeIndex = indexOfNode(id); 
	treeData[nodeIndex].open = status; 
	
	if (treeData[nodeIndex].parent == 'root')
	{
		if (status==1) {
		   if ((treeoldopen != 0) && (treeoldopen != id)) {
			   toggleFolder(treeoldopen, 0);
		   }
		   treeoldopen = id;
		
		}	
			
	}
	
	timeOutId = setTimeout("drawTree()",50)}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// indexOfNode() - GENERAL FUNCTION - finds the index in the treeData Collection of the node
//						  with the given id.
function indexOfNode(id) {
	var currentIndex = 1;
	while (currentIndex <= treeData.length) {
		if ((treeData[currentIndex].type == 'root') || (treeData[currentIndex].type == 'folder')) {
			if (treeData[currentIndex].id == id) {return currentIndex}} 
		currentIndex++} 
	return -1}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// extractChildrenOf() - GENERAL FUNCTION - extracts and returns a Collection containing all
//							  of the node's immediate children nodes.
function extractChildrenOf(node) {
	var children = new Collection();
	var currentIndex = 1; 
	while (currentIndex <= treeData.length) {
		if ((treeData[currentIndex].type == 'folder') || (treeData[currentIndex].type == 'link')) {
			if (treeData[currentIndex].parent == node) {
				children.add(treeData[currentIndex])}}
		currentIndex++} 
	return children}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Collection() - OBJECT - a dynamic storage structure similar to an Array.
function Collection() {
	this.length = 0; 
	this.add = add; 
	return this}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// add() - METHOD of Collection - adds an object to a Collection.
function add(object) {
	this.length++; 
	this[this.length] = object;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RootNode() - OBJECT - represents the top-most node of the hierarchial tree.

function RootNode(id,name,url,target,icon) {
	this.id = id;
	this.name = name;
	this.url = url;
	this.target = target;
	this.icon = icon;
	this.type = 'root';
	return this}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// FolderNode() - OBJECT - represents a node which branches to contain other nodes.

function FolderNode(id,parent,name,iconClosed,iconOpen) {
	this.id = id;
	this.parent = parent;
	this.name = name;
	this.iconClosed = iconClosed;
	this.iconOpen = iconOpen;
	this.type = 'folder';
	this.open = 0;
	return this}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





// LinkNode() - OBJECT - a node that represents a link using a URL.
function LinkNode(parent,name,url,target,icon) {
	this.parent = parent;
	this.name = name;
	this.url = url;
	this.target = target;
	this.icon = icon;
	this.type = 'link';
	return this}






function findparent(parent)
{
var currentIndex = 1;
var x = null;
while (currentIndex <= treeData.length) {


	if ((treeData[currentIndex].type == 'folder') || (treeData[currentIndex].type == 'root')) {

	

		if (treeData[currentIndex].name.toUpperCase( ) == parent.toUpperCase( )) {

		  x = treeData[currentIndex];
		} 



	}

currentIndex++} 
return(x);
}

function openlinkbynode(node)
{

			if (node.target == "") {
				var targetFrame = 'main';
				window.parent.frames[targetFrame].document.location = 'openpage.asp?puid='+getidpath(node) +'&page=' + escape(node.url);
 		}
			else {

if (node.target != "_top") {
var targetFrame = node.target
window.parent.frames[targetFrame].document.location = 'openpage.asp?puid='+getidpath(node) +'&page=' + escape(node.url);
}
}
	
}



function isvalidobject(objects)
{
  if (objects != null) {
//	if (objects !=undefined) {
//	  return(true);
//	} else return(false);	
  return(true);
  } else return(false);
}



function openbyindex(index)
{
  var currentIndex = 1;
  var node =  treeData[index];
  while (isvalidobject(node)) {
   if  (node.type == 'folder')
	{ 
	node.open = 1; 
	}
   if  ((node.type == 'link') || (node.type == 'root'))
	{ 
	openlinkbynode(node);
	}
	node = findparent(node.parent);
   }
	timeOutId = setTimeout("drawTree()",100);
}




function openlinkbyindex(idx)
{

 var node = treeData[idx];
			if (node.target == "") {
				var targetFrame = 'main';
				window.parent.frames[targetFrame].document.location = 'openpage.asp?puid='+getidpath(treeData[idx]) +'&page=' + escape(treeData[idx].url);
 		}
			else {


if (node.target != "_top") {
var targetFrame = node.target;
window.parent.frames[targetFrame].document.location = 'openpage.asp?puid='+getidpath(treeData[idx]) +'&page=' + escape(treeData[idx].url);

} 
  

}


}




// End Hiding -->