
// ===================== CH_Vertical_Menu_Bar Class ======================================

function CH_Vertical_Menu_Bar (strInstanceName, strCgiPath, strAssetsPath, strShowHome, strStartLevel)
{
	this.m_InstanceName = strInstanceName;
	this.m_CgiPath	    = strCgiPath;
	this.m_AssetsPath   = strAssetsPath;
	this.m_ShowHome	    = false;
	this.m_StartLevel   = 0;
	
	if (strShowHome != null && strShowHome == 'true')
		this.m_ShowHome = true;

	if (strStartLevel != '')
	{
		var value = parseInt(strStartLevel);
		if (value != NaN)
			this.m_StartLevel = value;
	}

	this.m_src_Space = strAssetsPath + 'space.gif';				
	this.m_arrowDownImage = strAssetsPath + 'ArrowDown.gif';
	this.m_arrowDownOverImage = strAssetsPath + 'ArrowDown_over.gif';
	this.m_arrowRightImage = strAssetsPath + 'ArrowRight.gif';
	this.m_arrowRightOverImage = strAssetsPath + 'ArrowRight_over.gif';	
		
	this.m_arrowRightImageWidth = "11";
	this.m_arrowRightImageHeight = "11";
	this.m_arrowDownImageWidth = "11";
	this.m_arrowDownImageHeight = "11";	

	this.m_HeaderTableId = strInstanceName + '_HeaderTable';
	this.m_HeaderMenuId  = strInstanceName + '_HeaderMenu';
	
	this.m_selectedElements = new Array(0);

	this.m_ds = new Array();
	this.m_di = 0;

	//document.write('<textarea>');
	// primary display 
	CH_Vertical_Menu_Bar.prototype.Display = CH_Vertical_Menu_Bar_Display;
	CH_Vertical_Menu_Bar.prototype.DisplayNode = CH_Vertical_Menu_Bar_DisplayNode;
	CH_Vertical_Menu_Bar.prototype.FindNode = CH_Vertical_Menu_Bar_FindNode;
	
	// content page generation
	CH_Vertical_Menu_Bar.prototype.OpeningHtml = CH_Vertical_Menu_Bar_OpeningHtml;
	CH_Vertical_Menu_Bar.prototype.CoreHtml = CH_Vertical_Menu_Bar_CoreHtml;
	CH_Vertical_Menu_Bar.prototype.ClosingHtml = CH_Vertical_Menu_Bar_ClosingHtml;	
	
	// runtime support
	CH_Vertical_Menu_Bar.prototype.topCollectionItem_mouseover	= CH_Vertical_Menu_Bar_topCollectionItem_mouseover;
	CH_Vertical_Menu_Bar.prototype.topCollectionItem_mouseout	= CH_Vertical_Menu_Bar_topCollectionItem_mouseout;
		
	CH_Vertical_Menu_Bar.prototype.childCollectionItem_mouseover = CH_Vertical_Menu_Bar_childCollectionItem_mouseover;
	CH_Vertical_Menu_Bar.prototype.childCollectionItem_mouseout	= CH_Vertical_Menu_Bar_childCollectionItem_mouseout;

	CH_Vertical_Menu_Bar.prototype.highlightItem					= CH_Vertical_Menu_Bar_highlightItem;
	CH_Vertical_Menu_Bar.prototype.unhighlightItem				= CH_Vertical_Menu_Bar_unhighlightItem;

	CH_Vertical_Menu_Bar.prototype.linkItem_mouseover			= CH_Vertical_Menu_Bar_linkItem_mouseover;
	CH_Vertical_Menu_Bar.prototype.linkItem_mouseout				= CH_Vertical_Menu_Bar_linkItem_mouseout;

	CH_Vertical_Menu_Bar.prototype.topCollectionItem_onclick		= CH_Vertical_Menu_Bar_topCollectionItem_onclick;
	CH_Vertical_Menu_Bar.prototype.childCollectionItem_onclick	= CH_Vertical_Menu_Bar_childCollectionItem_onclick;
	CH_Vertical_Menu_Bar.prototype.linkItem_onclick				= CH_Vertical_Menu_Bar_linkItem_onclick;

	CH_Vertical_Menu_Bar.prototype.closeChildMenusOf				= CH_Vertical_Menu_Bar_closeChildMenusOf;
	CH_Vertical_Menu_Bar.prototype.closeOpenSiblingsOf			= CH_Vertical_Menu_Bar_closeOpenSiblingsOf;

	CH_Vertical_Menu_Bar.prototype.setMenuDisplayStatus			= CH_Vertical_Menu_Bar_setMenuDisplayStatus;
	CH_Vertical_Menu_Bar.prototype.resetMenus					= CH_Vertical_Menu_Bar_resetMenus;
}

function CH_Vertical_Menu_Bar_Display(node)
{
	var foundNode = this.FindNode(node);

	if (foundNode == null || (foundNode.m_subNodes.length == 0 && !this.m_ShowHome))
	{
		document.write('&nbsp;');
		return;				// **** R E T U R N **** 
	}

	// else, we have a node to display

	this.m_ds[this.m_di++] = 
		'<!-- Header Table -->' + 
		'<table id="' + this.m_HeaderTableId + '" style="width:100%" border="0" cellspacing="0" cellpadding="0" >' +
//		'	<tr>' +
//		'		<td colspan="3" class="ddv_HeaderLogoCell">' +
//		'			<table style="width:100%" border="0" cellspacing="0" cellpadding="0">' +
//		'				<tr>' +
//		'					<td style="width:10px;text-align:left; vertical-align:middle; padding-left:6pt; padding-right:10px">' +
//		'						<img src="images/StellentLogo.gif" width="120" height="20"></td>' +
//		'					<td id="quickSearchCell" style="white-space:nowrap; text-align:right; vertical-align:middle; padding-left:0pt; padding-right:6pt; padding-top:5px; padding-bottom:7px">' +
//		'						<!-- *** Quick Search container *** --></td>' +
//		'				</tr>' +
//		' 			</table>' +
//		'		</td>' +
//		'	</tr>' +
		'	<tr>' +
		'		<td colspan="3" class="ddv_HeaderSpacerCell"><img src="' + this.m_src_Space + '" width="16" height="1"></td>' +
		'	</tr>' +
		'	<tr>' +
		'		<td id="' + this.m_HeaderMenuId + '" class="ddv_HeaderMenuCell" width="10">' +
		'';

// opening HTML for the Home node... but really binding the whole top level
		this.m_ds[this.m_di++] =
			'<table width="180px" border="0" cellpadding="0" cellspacing="0" >\n' +
			'';
// opening HTML

// core HTML
	this.DisplayNode(foundNode);		// recursive walk...
// core HTML
	
// closing HTML for the Home node...
		this.m_ds[this.m_di++] =
			'</table>\n';
// closing HTML for the Home node...

	this.m_ds[this.m_di++] = 
		'       </td>' +
//		'		<td class="ddv_TopMenuBarDividerCell" width="10">' +
//		'			<img src="images/tab_corner.gif" width="37" height="19"></td>' +
//		'		<td class="ddv_TopMenuBarRightCell">' +
//		'			<table border="0" cellpadding="0" cellspacing="0">' +
//		'				<tr>' +
//		'					<td class="ddv_TopMenuBarExtraLink" onclick="addBookmark()" onmouseover="this.className='ddv_TopMenuBarExtraLink_over'" onmouseout="this.className='ddv_TopMenuBarExtraLink'">' +
//		'						Add To Favorites</td>' +
//		'				</tr>' +
//		'			</table>' +
//		'		</td>' +
		'	</tr>' +
		'</table>' +	
		'';

//	alert(this.m_ds.join(''));

	document.write(this.m_ds.join(''));
}

function CH_Vertical_Menu_Bar_FindNode (node)
{
	var retNode = null;

	if (node.m_level == this.m_StartLevel && node.m_id == g_navNode_Path[this.m_StartLevel])
	{
		retNode = node;
	}
	else
	if (node.m_level < this.m_StartLevel)
	{
		for (var count = 0; count < node.m_subNodes.length; count++)
		{
			retNode = this.FindNode(node.m_subNodes[count]);
			
			if (retNode != null)
				break;
		}
	}
	return retNode;
}

function CH_Vertical_Menu_Bar_DisplayNode (parentElement, parentPath)
{
	// Create a variable containing all children of the passed-in element. 
	var childList = parentElement.m_subNodes;

	// Call the function that generates the opening html code for a collection (the generated
	// code will typically be an opening <div> tag that will act as a container for the collection).
	this.OpeningHtml(parentElement);

	if (parentElement.m_level == this.m_StartLevel && this.m_ShowHome)
		this.CoreHtml(parentElement, parentPath);

	// Loop through the children of the passed-in element. For each child, run the core html function,
	// and if that child has children of its own, recursively call the DisplayNode function.
	
	for (var i=0; i<childList.length; i++)
	{		
		var childNode = childList[i];
		
		if (parentPath)
		{
			var nodePath = parentPath + "." + i;
		}
		else
		{
			var nodePath = i.toString();
		}

		this.CoreHtml(childNode, nodePath);

		if (childNode.m_subNodes.length > 0)
		{
			this.DisplayNode(childNode, nodePath);
		}
	}

	/* Call the function that generates the closing html code for a collection (the generated
		code will typically be a closing </div> tag for the collection container).*/
		
	this.ClosingHtml(parentElement);
}

// ============== Page Data Generation functions ========================


function CH_Vertical_Menu_Bar_OpeningHtml(parentElement)
{
	var level = parentElement.m_level;

//	if (level == this.m_StartLevel && this.m_ShowHome)
//		level = 1;	// fake it...

	if (level == this.m_StartLevel) // Home node
	{

	}
	else 
	if (level == this.m_StartLevel+1) // Top-level menu items
	{
		this.m_ds[this.m_di++] =
			'<div class="ddv_TopChildCollectionContainer" style="display:none">\n' +
			'	<table class="ddv_TopChildListTable" border="0" cellpadding="0" cellspacing="0" >\n' +
			'		<tr>\n' +
			'			<td>\n' +
			'				<img src="' + this.m_src_Space + '" width="1" height="2"></td>\n' +
			'		</tr>\n';
	}
	else // Sub-tier child menus.
	{
		this.m_ds[this.m_di++] =
			'<div class="ddv_SubChildCollectionContainer" style="display:none">\n' +
			'	<table class="ddv_SubChildListTable" border="0" cellpadding="0" cellspacing="0">\n' +
			'		<tr>\n' +
			'			<td>\n' +
			'				<img src="' + this.m_src_Space + '" width="1" height="2"></td>\n' +
			'		</tr>\n';
	}
}

function CH_Vertical_Menu_Bar_CoreHtml(childElement, nodeLocation)
{
	var label = childElement.m_label;
	var id = nodeLocation;

	var level = childElement.m_level;

	if (level == this.m_StartLevel && this.m_ShowHome)
		level = this.m_StartLevel+1;	// fake it...
	
	if (level == this.m_StartLevel) // Home node
	{
	
	}
	else
	if (level == this.m_StartLevel+1) // Top-level menu items
	{
		var linkTarget = "_self";
		var url = childElement.m_href.replace(/'/g, "\\'");
		
		if (childElement.m_subNodes.length == 0 || childElement.m_level == this.m_StartLevel)
		{	// "item"
			this.m_ds[this.m_di++] =
/* bjn */		'<tr>' +			
				'<td id="' + id + '" class="ddv_TopLinkItem"' +
				' onclick="' + this.m_InstanceName + '.linkItem_onclick(event, this, \'' + url + '\', \'' + linkTarget + '\')"' +
				' onmouseover="' + this.m_InstanceName + '.linkItem_mouseover(this)"' + 
				' onmouseout="' + this.m_InstanceName + '.linkItem_mouseout(this)">\n' +
				'	' + label + '\n' +
				'</td>\n' +
/* bjn */		'</tr>' +
				'';
		}
		else 
		{	// "collection"
			this.m_ds[this.m_di++] =
/* bjn */		'<tr>' + 
				'<td id="' + id + '"' +
// bjn2			' onclick="' + this.m_InstanceName + '.topCollectionItem_onclick(event, this)"' +
/* bjn2	*/		' onclick="' + this.m_InstanceName + '.linkItem_onclick(event, this, \'' + url + '\', \'' + linkTarget + '\')"' +
				' onmouseover="' + this.m_InstanceName + '.topCollectionItem_mouseover(event, this)"' +
				' onmouseout="' + this.m_InstanceName + '.topCollectionItem_mouseout(event, this)">\n' +
/* bjn */		'	<table class="ddv_TopCollectionItemTable" style="width:100%" border="0" cellpadding="0" cellspacing="0" >\n' +
				'		<tr>\n' +
// bjn				'			<td class="ddv_TopCollectionItemArrowCell">\n' +
// bjn				'				<img src="' + this.m_arrowDownImage + '" width="' + this.m_arrowDownImageWidth + '" height="' + this.m_arrowDownImageHeight + '"></td>\n' +
// bjn				'			<td class="ddv_TopCollectionItem">\n' +
// bjn				'				' + label + '</td>\n' +
/* bjn */		'			<td class="ddv_TopCollectionItem">\n' +
/* bjn */		'				' + label + '</td>\n' +
/* bjn */		'			<td class="ddv_TopCollectionItemArrowCell">\n' +
/* bjn */		'				<img src="' + this.m_arrowRightImage + '" width="' + this.m_arrowRightImageWidth + '" height="' + this.m_arrowRightImageHeight + '"></td>\n' +
				'		</tr>\n' +
				'	</table>\n' +
				'';
				
		}
	}
	else // Child menu items
	{
		var linkTarget = "_self";
		var url = childElement.m_href.replace(/'/g, "\\'");
		
		if (childElement.m_subNodes.length == 0)
		{	// "item"
			this.m_ds[this.m_di++] =
				'<tr>\n' +
				'	<td id="' + id + '" class="ddv_ChildLinkItem"' +
				'   onclick="' + this.m_InstanceName + '.linkItem_onclick(event, this, \'' + url + '\', \'' + linkTarget + '\')"' +
				'   onmouseover="' + this.m_InstanceName + '.linkItem_mouseover(this)"' +
				'   onmouseout="' + this.m_InstanceName + '.linkItem_mouseout(this)">\n' +
				'	' + label + '\n' +
				'	</td>\n' +
				'</tr>\n';
		}
		else 
		{ // "collection"
			this.m_ds[this.m_di++] =			
				'<tr>\n' +
				'	<td id="' + id + '"' +
// bjn2		'       onclick="' + this.m_InstanceName + '.childCollectionItem_onclick(event, this)"' +
/* bjn2 */		'   onclick="' + this.m_InstanceName + '.linkItem_onclick(event, this, \'' + url + '\', \'' + linkTarget + '\')"' +
				'       onmouseover="' + this.m_InstanceName + '.childCollectionItem_mouseover(event, this)"' +
				'       onmouseout="' + this.m_InstanceName + '.childCollectionItem_mouseout(event, this)">\n' +
				'		<table class="ddv_ChildCollectionItemTable" style="width:100%" border="0" cellpadding="0" cellspacing="0">\n' +
				'			<tr>\n' +
				'				<td class="ddv_ChildCollectionItem">\n' +
				'					' + label + '</td>\n' +
				'				<td class="ddv_ChildCollectionItemArrowCell">\n' +
				'					<img src="' + this.m_arrowRightImage + '" width="' + this.m_arrowRightImageWidth + '" height="' + this.m_arrowRightImageHeight + '"></td>\n' +
				'			</tr>\n' +
				'		</table>\n';
		}
	}
}

function CH_Vertical_Menu_Bar_ClosingHtml(parentElement)
{
	var level = parentElement.m_level;

//	if (level == this.m_StartLevel && this.m_ShowHome)
//		level = this.m_StartLevel+1;	// fake it...

	if (level == this.m_StartLevel) // Home node
	{

	}
	else 
	if (level == this.m_StartLevel+1) // Top-level menu items
	{
		this.m_ds[this.m_di++] =
			'			<tr>\n' +
			'				<td>\n' +
			'					<img src="' + this.m_src_Space + '" width="1" height="2"></td>\n' +
			'			</tr>\n' +
			'		</table>\n' +
			'	</div>\n' +
			'   </td>\n' + // Closing tag for parent cell
/* bjn */	'</tr>\n' + // Closing tag for parent row.
			'';			
	}
	else // Sub-tier child menus
	{
		this.m_ds[this.m_di++] =
			'			<tr>\n' +
			'				<td>\n' +
			'					<img src="' + this.m_src_Space + '" width="1" height="2"></td>\n' +
			'			</tr>\n' +
			'		</table>\n' +
			'	</div>\n' +
			'	</td>\n' + // Closing tag for parent cell.
			'</tr>\n'; // Closing tag for parent row.
	}
}

// ============= Runtime Support Functions =============================

function CH_Vertical_Menu_Bar_topCollectionItem_mouseover(e, element)
{
	if (navigator.appName == "Netscape")
	{
		this.highlightItem(element);
	}
	else //IE Branch
	{						
		this.highlightItem(element);

		var headerTable = document.getElementById(this.m_HeaderTableId);
		var headerTop = parseInt(headerTable.offsetTop);		
		var headerLeft = parseInt(headerTable.offsetLeft);		

		var trikLeft = 0;
		var trikTop = 0;
		
		var container = headerTable.offsetParent;	
	
		while (container)
		{
			trikLeft += container.offsetLeft;
			trikTop += container.offsetTop;			
			container = container.offsetParent;
		}

		var menuBottomBorder = parseInt(document.getElementById(this.m_HeaderMenuId).currentStyle.borderBottomWidth);
		var menuBottomPadding = parseInt(document.getElementById(this.m_HeaderMenuId).currentStyle.paddingBottom);

		if (isNaN(menuBottomBorder)) { menuBottomBorder = 0 }
		if (isNaN(menuBottomPadding)) { menuBottomPadding = 0 }

		if (element.getElementsByTagName("div").length > 0)
		{
			var childMenu = element.getElementsByTagName("div")[0];

			childMenu.style.top = trikTop + headerTop + element.offsetTop;
			childMenu.style.left = trikLeft + headerLeft + element.offsetLeft + element.offsetWidth;

			childMenu.style.display = "block";

			this.setMenuDisplayStatus(childMenu, "on");
		}		
	}
}

function CH_Vertical_Menu_Bar_topCollectionItem_mouseout(e, element)
{
	if (!e) { e = window.event; }		

	if (navigator.appName == "Netscape") //NN/Mozilla
	{
		if (element.getElementsByTagName("div").length > 0)
		{		
			var childMenu = element.getElementsByTagName("div")[0];
			if (childMenu.style.display == "none")
			{
				this.unhighlightItem(element);
			}
		}
	}
	else // IE
	{
		this.unhighlightItem(element);

		if (element.getElementsByTagName("div").length > 0)
		{			
			var childMenu = element.getElementsByTagName("div")[0];
			childMenu.style.display = "none";

			this.setMenuDisplayStatus(childMenu, "off");
		}
	}
}

function CH_Vertical_Menu_Bar_childCollectionItem_mouseover(e, element)
{
	if (navigator.appName == "Netscape")
	{
		this.highlightItem(element);
	}
	else
	{
		this.highlightItem(element);
		
		if (element.getElementsByTagName("div").length > 0)
		{					
			var childMenu = element.getElementsByTagName("div")[0];
			childMenu.style.top = element.offsetTop;
			childMenu.style.display = "block";

			this.setMenuDisplayStatus(childMenu, "on");
		}
	}
}

function CH_Vertical_Menu_Bar_highlightItem(element)
{
	var itemDisplayTable = element.getElementsByTagName("table")[0];

	// Set style for item's display table element.
	if (itemDisplayTable.className == "ddv_TopCollectionItemTable")
	{
		itemDisplayTable.className = "ddv_TopCollectionItemTable_over";
	}
	else if (itemDisplayTable.className == "ddv_ChildCollectionItemTable")
	{
		itemDisplayTable.className = "ddv_ChildCollectionItemTable_over";
	}

	var tableCells = itemDisplayTable.getElementsByTagName("td")
	for (var i=0; i<tableCells.length; i++)
	{
		// Set style for item's label cell element.
		if (tableCells[i].className == "ddv_TopCollectionItem")
		{
			tableCells[i].className = "ddv_TopCollectionItem_over";
		}
		else if (tableCells[i].className == "ddv_ChildCollectionItem")
		{
			tableCells[i].className = "ddv_ChildCollectionItem_over";
		}

		// Change arrow image to mouseover version.
		if (tableCells[i].className == "ddv_TopCollectionItemArrowCell")
		{
// bjn		tableCells[i].getElementsByTagName("img")[0].src = this.m_arrowDownOverImage;
/* bjn */	tableCells[i].getElementsByTagName("img")[0].src = this.m_arrowRightOverImage;
		}
		else if (tableCells[i].className == "ddv_ChildCollectionItemArrowCell")
		{
			tableCells[i].getElementsByTagName("img")[0].src = this.m_arrowRightOverImage;
		}
	}
}

function CH_Vertical_Menu_Bar_childCollectionItem_mouseout(e, element)
{
	if (!e) { e = window.event; }

	if (navigator.appName == "Netscape") // NN/Mozilla
	{
		if (element.getElementsByTagName("div").length > 0)
		{				
			var childMenu = element.getElementsByTagName("div")[0];
			if (childMenu.style.display == "none")
			{
				this.unhighlightItem(element);
			}
		}				
	}

	else // IE
	{
		this.unhighlightItem(element);

		if (element.getElementsByTagName("div").length > 0)
		{					
			var childMenu = element.getElementsByTagName("div")[0];
			childMenu.style.display = "none";

			this.setMenuDisplayStatus(childMenu, "off");
		}
	}
}

function CH_Vertical_Menu_Bar_unhighlightItem(element)
{
	var itemDisplayTable = element.getElementsByTagName("table")[0];

	// Set style for item's display table element.
	if (itemDisplayTable.className == "ddv_TopCollectionItemTable_over")
	{
		itemDisplayTable.className = "ddv_TopCollectionItemTable";
	}
	else if (itemDisplayTable.className == "ddv_ChildCollectionItemTable_over")
	{
		itemDisplayTable.className = "ddv_ChildCollectionItemTable";
	}

	var tableCells = itemDisplayTable.getElementsByTagName("td")
	for (var i=0; i<tableCells.length; i++)
	{

		// Set style for item's label cell element.
		if (tableCells[i].className == "ddv_TopCollectionItem_over")
		{
			tableCells[i].className = "ddv_TopCollectionItem";
		}
		else if (tableCells[i].className == "ddv_ChildCollectionItem_over")
		{
			tableCells[i].className = "ddv_ChildCollectionItem";
		}

		// Change arrow image to mouseover version.
		if (tableCells[i].className == "ddv_TopCollectionItemArrowCell")
		{
// bjn		tableCells[i].getElementsByTagName("img")[0].src = this.m_arrowDownImage;
/* bjn */	tableCells[i].getElementsByTagName("img")[0].src = this.m_arrowRightImage;
		}
		else if (tableCells[i].className == "ddv_ChildCollectionItemArrowCell")
		{
			tableCells[i].getElementsByTagName("img")[0].src = this.m_arrowRightImage;
		}

	}
}

function CH_Vertical_Menu_Bar_linkItem_mouseover(element)
{		
	if (element.className == "ddv_TopLinkItem")
	{
		element.className = "ddv_TopLinkItem_over";
	}

	else if (element.className == "ddv_ChildLinkItem")
	{
		element.className = "ddv_ChildLinkItem_over";
	}				
}

function CH_Vertical_Menu_Bar_linkItem_mouseout(element)
{
	if (element.className == "ddv_TopLinkItem_over")
	{
		element.className = "ddv_TopLinkItem";
	}

	else if (element.className == "ddv_ChildLinkItem_over")
	{
		element.className = "ddv_ChildLinkItem";
	}
}

function CH_Vertical_Menu_Bar_topCollectionItem_onclick(e, element)
{
	var headerTable  = document.getElementById(this.m_HeaderTableId);
	var headerHeight = headerTable.offsetHeight;

	var trikLeft = 0;
	var trikTop = 0;
	
	var container = headerTable.offsetParent;				
	while (container)
	{
		trikLeft += container.offsetLeft;
		trikTop += container.offsetTop;			
		container = e.offsetParent;
	}

	if (navigator.appName == "Netscape")
	{
		if (element.getElementsByTagName("div").length > 0)
		{				
			var childMenu = element.getElementsByTagName("div")[0];

			if (childMenu.style.display == "none")
			{
				this.resetMenus();
				childMenu.style.top = headerHeight + trikTop;
				childMenu.style.left = element.offsetLeft + trikLeft;
				childMenu.style.display = "block";
				this.setMenuDisplayStatus(childMenu, "on");
			}
			else if (childMenu.style.display == "block")
			{
				this.resetMenus();
				this.highlightItem(element);
				/* Note: have to rehighlight the element since the mouse is logically
					still over this element, and the closeChildMenusOf function loop sets parent
					elements of ALL child menus (including the target) back to regular style */
			}
		}

		e.stopPropagation();
	}

	else // IE Branch
	{
		e.cancelBubble = true;
	}
}

function CH_Vertical_Menu_Bar_childCollectionItem_onclick(e, element)
{
	if (navigator.appName == "Netscape")
	{
		if (element.getElementsByTagName("div").length > 0)
		{				
			var childMenu = element.getElementsByTagName("div")[0];

			if (childMenu.style.display == "none")
			{
				this.closeOpenSiblingsOf(element);
				childMenu.style.top = element.offsetTop;
				childMenu.style.left = element.offsetParent.offsetWidth;
				childMenu.style.display = "block";
				this.setMenuDisplayStatus(childMenu, "on");
			}
			else if (childMenu.style.display == "block")
			{
				this.closeChildMenusOf(element);
				this.highlightItem(element);
				/* Note: have to rehighlight the element since the mouse is logically
					still over this element, and the closeChildMenusOf function loop sets parent
					elements of ALL child menus (including the target) back to regular style */
			}
		}

		e.stopPropagation();
	}
	else // IE Branch
	{
		e.cancelBubble = true;
	}
}

function CH_Vertical_Menu_Bar_linkItem_onclick(e, element, url, target)
{
	if (target == "")
	{
		target = "_self";
	}
	window.open(url, target);
	this.resetMenus();

	if (navigator.appName == "Netscape")
	{
		if (element.className == "ddv_ChildLinkItem_over")
		{
			element.className = "ddv_ChildLinkItem";
		}
		else if (element.className == "ddv_TopLinkItem_over")
		{
			element.className = "ddv_TopLinkItem";
		}			
		e.stopPropagation();
	}
// bjn 
	else // IE Branch
	{
		e.cancelBubble = true;
	}
}

function CH_Vertical_Menu_Bar_closeChildMenusOf(element)
// Closes an element's associated child menu as well as all decendents of that menu.
{ 
	var decendentMenus = element.getElementsByTagName("div");

	for (var i=decendentMenus.length-1; i>=0; i--)
	{
		var childMenu = decendentMenus[i];		

		this.unhighlightItem(childMenu.parentNode);
		
		childMenu.style.display = "none";

		this.setMenuDisplayStatus(childMenu, "off");
	}
}

function CH_Vertical_Menu_Bar_closeOpenSiblingsOf(element)
{
	var hierarchyLevel = element.id.split(".").length;
	
	if (hierarchyLevel == 1) // Top-level items
	{
		var siblingCellElements = element.parentNode.cells;
		
		for (var i=0; i<siblingCellElements.length; i++)
		{
			var siblingCellElement = siblingCellElements[i];
			
			if (siblingCellElement.getElementsByTagName("div").length > 0)
			{
				if (siblingCellElement.getElementsByTagName("div")[0].style.display == "block" && siblingCellElement != element)
				{
					this.closeChildMenusOf(siblingCellElement);
				}
			}				
		}			
	}
	else // Sub-level items
	{
		var siblingRowElements = element.parentNode.parentNode.rows; // Note: had to use parentNode twice to get past the TBODY element to the TABLE element.

		for (var i=0; i<siblingRowElements.length; i++)
		{
			var siblingCellElement = siblingRowElements[i].cells[0];

			if (siblingCellElement.getElementsByTagName("div").length > 0)
			{
				if (siblingCellElement.getElementsByTagName("div")[0].style.display == "block" && siblingCellElement != element)
				{
					this.closeChildMenusOf(siblingCellElement);
				}
			}
		}
	}
}

function CH_Vertical_Menu_Bar_setMenuDisplayStatus(menuElement, status)
/* This function uses a global array (defined above) to record element references
	to all menu containers that are currently visible. */
{
	if (status == "on")
	{
		/* If setting status to "on", add the element to the selectedElements array. */
		var alreadyOn = false;
		for (var i=0; i<this.m_selectedElements.length; i++)
		{
			if (this.m_selectedElements[i] == menuElement)
			{
				alreadyOn = true;
				break;
			}
		}

		if (!alreadyOn)
		{
			this.m_selectedElements.push(menuElement);
		}
	}
	else if (status == "off")
	{
		/* If setting status to "off", loop through the selectedElements array and
			find the array item that matches the current menu element and remove it
			from the array. */
		for (var i=0; i<this.m_selectedElements.length; i++)
		{
			if (this.m_selectedElements[i] == menuElement)
			{
				this.m_selectedElements.splice(i, 1); //Removes the selected element from the array.
				break;
			}
		}
	}
}

function CH_Vertical_Menu_Bar_resetMenus(e)
{
	var i = 0;
	var topLevelMenuCell = document.getElementById(i.toString());
	while (topLevelMenuCell != null)
	{			
		if (topLevelMenuCell.getElementsByTagName("div").length > 0 && topLevelMenuCell.getElementsByTagName("div")[0].style.display == "block")
		{
			this.closeChildMenusOf(topLevelMenuCell);
		}
		i++;
		topLevelMenuCell = document.getElementById(i.toString());
	}

	this.m_selectedElements.length = 0; // Clear out the array.
}

// ==================== the end ===========================
