//////////////////////////////////////////////////////////////
//
// YOU SHOULD NEVER MODIFY THIS FILE!
//
// If you wish to modify a layout, you should place all your code
//   in the function 'initCustomNodes' in the 'nav.js' file.
//
// If you are writing a component, you should override the include
//   'custom_finish_layout_init' with the 'super' tag, and modify
//   the 'navBuilder' object there.
//
// If you wish to make modifications that require changes to this
//   file, you should instead create en entirely new layout based
//   on this one.
//
//////////////////////////////////////////////////////////////

/* Configuration variable: if set to false, trays will be eliminated and the
   left navigation area will become a single, connected tree of collections and
   items. */
var useTrays = true;

/* Configuration variable: if set to true, the user can have more than one tray
   open at a time; if set to 'false', only one tray can be open at a time
   (currently-open tray will automatically close when a new tray is opened). */
var allowMultipleTrays = false;


/* IMAGE DEFINITION CODE *************************************************/
/*************************************************************************/

/* Nav tree image src values. */
var src_leftNav = httpLayoutRoot + "left_nav.htm";
var src_I = httpSkinRoot + "tree_I.gif";
var src_Icon_ColClosed = httpSkinRoot + "tree_icon_collection_closed.gif";
var src_Icon_ColOpen = httpSkinRoot + "tree_icon_collection_open.gif";
var src_Icon_Item = httpSkinRoot + "tree_icon_item.gif";
var src_L_ColClosed = httpSkinRoot + "tree_L_collection_closed.gif";
var src_L_ColOpen = httpSkinRoot + "tree_L_collection_open.gif";
var src_T_ColClosed = httpSkinRoot + "tree_T_collection_closed.gif";
var src_T_ColOpen = httpSkinRoot + "tree_T_collection_open.gif";
var src_L_Item = httpSkinRoot + "tree_L_item.gif";
var src_T_Item = httpSkinRoot + "tree_T_item.gif";
var src_tree_space = httpSkinRoot + "tree_space.gif";
var src_space = httpSkinRoot + "space.gif";
var src_Top_ColClosed = httpSkinRoot + "tree_top_collection_closed.gif";
var src_Top_ColOpen = httpSkinRoot + "tree_top_collection_open.gif";
var src_TopOnly_ColClosed = httpSkinRoot + "tree_top_only_collection_closed.gif";
var src_TopOnly_ColOpen = httpSkinRoot + "tree_top_only_collection_open.gif";
var src_Top_Item = httpSkinRoot + "tree_top_item.gif";
var src_TopOnly_Item = httpSkinRoot + "tree_top_only_item.gif";
var trayA_ArrowRight = httpSkinRoot + "trayA_arrow_right.gif";
var trayA_ArrowDown = httpSkinRoot + "trayA_arrow_down.gif";
var trayTabLeftSide_InFront = httpSkinRoot + "TrayTabLeftSide_InFront.gif";
var trayTabLeftSide_InBack = httpSkinRoot + "TrayTabLeftSide_InBack.gif";
var trayTabRightSide_InFront = httpSkinRoot + "TrayTabRightSide_InFront.gif";
var trayTabRightSide_InBack = httpSkinRoot + "TrayTabRightSide_InBack.gif";
var trayA_TrayCorner = httpSkinRoot + "TrayCorner.gif";

/* Nav tree image height and width values. */
var iconWidth_Col = "16";
var iconHeight_Col = "16";
var iconWidth_Item = "16";
var iconHeight_Item = "16";
var connectorWidth = "12";
var connectorHeight = "20";
var arrowRightImageWidth = "11";
var arrowRightImageHeight = "11";
var arrowDownImageWidth = "11";
var arrowDownImageHeight = "11";

/* Header/menu bar image src values */
var logoImage = httpSkinRoot + "HeaderLogo.gif";

var menuBarDividerImage = httpSkinRoot + "menu_bar_divider.gif";
var menuA_arrowDownImage = httpSkinRoot + "menuA_ArrowDown.gif";
var menuA_arrowDownOverImage = httpSkinRoot + "menuA_ArrowDown_over.gif";
var menuA_arrowRightImage = httpSkinRoot + "menuA_ArrowRight.gif";
var menuA_arrowRightOverImage = httpSkinRoot + "menuA_ArrowRight_over.gif";

/* needed to keep IE and Mozilla happy with https */
var blankPageUrl = src_space;

/* placeholder for the search tray urls */
var searchTrayTabArray = [ ["tab_0", httpCgiPath + "?IdcService=GET_DOC_PAGE&Action=GetTemplatePage&Page=TRAY_SEARCH_FORM"],
						   ["tab_1", ""] ];


/* PAGE DISPLAY INITIALIZATION CODE ****************************************/
/***************************************************************************/

function writeLayoutPageBegin()
{
	var beginHtml = "";
	var coreContentInitDisplay="block";

	/* These variables compensate for the fact that NN/Moz uses the total width
	   or height of a parent as the basis for setting relative table dimensions,
	   rather than the available width or height (total width or height minus
	   padding). */
	var mainContentTableHeight = "100%";
	var coreContentTableWidth = "100%";
	var pageContentDivWidth = "100%";
	var pageContentDivHeight = "100%";
	var navShellDivWidth = "100%";
	var navShellDivHeight = "100%";
	if (its.mozilla || its.nn)
	{
		mainContentTableHeight = "98%";
		coreContentTableWidth = "97%";
		pageContentDivWidth = "98%";
		pageContentDivHeight = "100%";
		navShellDivWidth = "99.9%"
		navShellDivHeight = "99.9%";
	}
	if (its.firefox)
	{
		navShellDivWidth = "99.8%"
		navShellDivHeight = "99.8%";
	}
	if (its.safari)
	{
		pageContentDivWidth = "98%";
	}

	if (!coreContentOnly && !parent.leftNavWindow)
	{
		if (isPostRequest && typeof isContentServerError != "undefined" && isContentServerError)
		{
			// In the event a Content Server error has occurred
			// we can't draw the navigation controls because it
			// clobbers the existence of the error message.
			return;
		}
		coreContentInitDisplay="none";
		var dragBarSpacerImg = "";
		if (its.safari)
			dragBarSpacerImg = '<img src="'+src_space+'" width="1" height="100%">';

		beginHtml +=
		'<!-- Begin Navigation Shell container -->\n' +
		'<div id="navShell" style="display:none; width:'+navShellDivWidth+
		'; height:'+navShellDivHeight+'">\n' +
		'<table style="width:100%; height:100%" border="0" cellspacing="0" cellpadding="0">\n' +
		'<tr>\n' +
		'<td style="height:10px">\n' +
		'	<!-- Header Table -->\n' +
		'	<table id="headerTable" style="width:100%" border="0" cellspacing="0" cellpadding="0">\n' +
		'		<tr>\n' +
		'			<td colspan="4" class="menuA_HeaderLogoCell">\n' +
		'				<table style="width:100%" border="0" cellspacing="0" cellpadding="0">\n' +
		'					<tr>\n' +
		'						<td class="logoImageCell">\n' +
		'							<img src="' + logoImage + '"></td>\n' +
		'						<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" nowrap>\n' +
		'							<!-- *** Quick Search container *** --></td>\n' +
		'					</tr>\n' +
		'				</table>\n' +
		'			</td>\n' +
		'		</tr>\n' +
		'		<tr>\n' +
		'			<td colspan="4" class="menuA_HeaderSpacerCell"><img src="' + src_tree_space + '" width="16" height="1"></td>\n' +
		'		</tr>\n' +
		'		<tr>\n' +
		'			<td id="menuA" class="menuA_HeaderMenuCell" width="10">\n' +
		'					<!-- *** Header Menu container *** --></td>\n' +
		'			<td class="menuA_TopMenuBarDividerCell" width="10">\n' +
		'					<img src="' + menuBarDividerImage + '" width="37" height="19"></td>\n' +
		'			<td id="menuBarExtrasCell" class="menuA_TopMenuBarRightCell">\n' +
		'				<!-- *** Menu Bar Extras container *** --></td>\n' +
		'		</tr>\n' +
		'	</table>\n' +
		'</td>\n' +
		'</tr>\n' +
		'<tr>\n' +
		'<td class="frameParentCell" style="vertical-align:top">\n' +
		'	<!-- Content Parent Table -->\n' +
		'	<div id="pageMask" style="position:absolute;background-image:url(' + src_tree_space + ');display:none"></div>\n' +
		'	<table style="width:100%;height:' + mainContentTableHeight + ';background:#FFFFFF" border="0" cellspacing="0" cellpadding="0">\n' +
		'		<tr>\n' +
		'			<td id="leftNavCell" class="leftNavFrameCell" style="width:200px">\n' +
		'				<iframe name="leftNavWindow" id="leftNavWindow" style="width:100%;height:100%" frameborder="0" scrolling="no" src="' + src_leftNav + '">\n' +
		'				</iframe>\n' +
		'			</td>\n' +
		'			<td class="frameDividerCell" onmousedown="sizePageColumns(event)" onmouseover="this.style.cursor=\'e-resize\'">\n' +
		'				' + dragBarSpacerImg + '<div id="dragBar" class="frameDividerCell" style="position:absolute;"></div>\n' +
		'			</td>\n' +
		'			<td id="contentCell" class="contentFrameCell">\n' +
		'				<iframe name="contentFrame" id="contentFrame" class="contentIFrame" style="width:100%;height:100%" frameborder="0" src="'+blankPageUrl+'">\n' +
		'				</iframe>\n' +
		'			</td>\n' +
		'		</tr>\n' +
		'	</table>\n' +
		'	<iframe name="hiddenActionWindow" id="hiddenActionWindow" style="position:absolute;left:-10px;visibility:hidden;width:0px;height:0px" src="'+blankPageUrl+'">\n' +
		'	</iframe>\n' +
		'</td>\n' +
		'</tr>\n' +
		'</table>\n' +
		'</div>\n';
	} // end if !coreContentOnly

	beginHtml +=
	'<!-- Begin Page Content container to be used for coreContentOnly page load.\n' +
	'(closing tag in std_page_end include) -->\n' +
	'<div id="pageContent" style="display:' + coreContentInitDisplay + ';width:' + 
		pageContentDivWidth + ';height:' + pageContentDivHeight +
        ';vertical-align:top;">\n' +
    '   <!-- Main display area table -->\n' +
    '   <table style="width:' + coreContentTableWidth + ';height:100%" border="0" cellspacing="0" cellpadding="0">\n' +
    '      <tr height="12px"><td></td></tr>\n' +
    '      <tr>\n' +
    '        <td width="10px"></td><td align="center" style="vertical-align:top">\n';

	document.write(beginHtml);
	document.close();
}


function writeLayoutPageEnd()
{
	var endHtml =
    '          </td><td width="10px"></td>\n' +
    '      </tr>\n' +
    '      <tr height="10px"><td></td></tr>\n' +
    '   </table>\n' + // End main display area table, this is where layout end should be
    '</div>\n'; // End Page Content container (opening tag is in std_main_page_begin include

	document.write(endHtml);
	document.close();
}


function layoutInitialize()
{
	if (window.name == "hiddenActionWindow" ||
		(isPostRequest && typeof isContentServerError != "undefined" && isContentServerError))
	{
		// do nothing
		// In the event a Content Server error has occurred
		// we can't draw the navigation controls because it 
		// clobbers the existence of the error message.  The
		// user will see a very undecorated page in this very
		// rare case.
		return;
	}
	if (window.name != "contentFrame")
	{
		var navShell = document.getElementById("navShell");
		if (navShell)
		{
			navShell.style.display = "block";
		}
		loadPageContents();

		// make sure the left_nav was generated
		if (leftNavWindow.location != src_leftNav)
			leftNavWindow.location.replace(src_leftNav);
	}
	else
	{
		var content = document.getElementById("pageContent");
		if (content != null)
			content.style.display = "block";
	}
}

var loadPageContentsOnceMore = false; 
function loadPageContents()
{
	// Don't attempt to load until all windows exist. Need the onceMore catch
	// for Safari and Firefox
	if (leftNavWindow && contentFrame && loadPageContentsOnceMore) 
	{
		if (queryString == null || queryString.length == 0)
		{
			queryString = 
				"IdcService=GET_DOC_PAGE&Action=GetTemplatePage&Page=HOME_PAGE";
		}
		contentFrame.location.replace(httpBrowserFullCgiPath + "?" + queryString);
	}
	else
	{
		loadPageContentsOnceMore = true;
		var delay = 100;
		if (its.mozilla)
			delay = 1000;
		setTimeout("loadPageContents()", delay);
	}
}


/* This function is called by the onload event of the nav_display.htm document. */
function generateNavigation()
{
	// init the top menu with just links
	coreNav.menuA = new navBuilder();
	coreNav.menuA.topLevelNodes = new Array (
		"LOGIN", "MICROSOFT_LOGIN", "SELF_REGISTRATION",
		"HOME", "LOCAL_HOME", "SEARCH",
		"NEW_CHECK_IN", "MY_PROFILE", "HELP");
	coreNav.menuA.makeOpeningHtml = menuA_MenuItem_OpeningHtml;
	coreNav.menuA.makeCoreHtml = menuA_MenuItem_CoreHtml;
	coreNav.menuA.makeClosingHtml = menuA_MenuItem_ClosingHtml;

	// init the top menu with the drop-down lists
	coreNav.trayA = new navBuilder();
	coreNav.trayA.topLevelNodes = new Array (
		"MY_STELLENT", "BROWSE_CONTENT", "SEARCH_TRAY", "PORTLET_1",
		"CONTENT_MANAGEMENT", "ADMINISTRATION" );
	coreNav.trayA.makeOpeningHtml = trayA_Item_OpeningHtml;
	coreNav.trayA.makeCoreHtml = trayA_Item_CoreHtml;
	coreNav.trayA.makeClosingHtml = trayA_Item_ClosingHtml;

	/* This function generates an associative array object containing pointers to
		all the elements in the master XML tree; this enables elements to be randomly
		accessed using the getNodeById() funciton. */
	mapXMLTree(coreNav.xmlRoot, coreNav.xmlNodeMap);
	//DEBUG_displayNodeMap(xmlNodeMap);

	/* initialize the navigation nodes */
	addStandardNavigationNodes(coreNav);

	/* add custom nodes - be careful of JavaScript errors */
	try
	{
		initCustomNodes(coreNav);
		finishLayoutInit(coreNav);
	}
	catch (e)
	{
		alert("layout.js: " + e);
	}

	//DEBUG_displayNodeMap(coreNav.xmlNodeMap);

//***** MENU BAR CODE *************************************

	/* Run the routine that copies nodes from the master XML document to the
	   dropdown menu XML fragment. The coreNav.menuA.topLevelNodes array is
	   passed in as a parameter to provide the list of nodes to be included in
	   this display group (coreNav.menuA.topLevelNodes is loaded in nav.js). */
	buildTopLevelItems(coreNav.menuA.topLevelNodes, coreNav.menuA.xmlRoot, coreNav);

	/* Create a map of the XML fragment to be used by the getNodeById() funciton. */
	coreNav.menuA.xmlNodeMap = new Object();
	mapXMLTree(coreNav.menuA.xmlRoot, coreNav.menuA.xmlNodeMap);
	//DEBUG_displayNodeMap(coreNav.menuA.xmlNodeMap);

	/* Ensure the menuA htmlString variable is empty before generating menu code. */
	coreNav.menuA.htmlString = "";

	/* Run the routine that recursively generates HTML code from the dropdown
	   menu XML fragment. */
	coreNav.menuA.buildHtmlStringFromXml(coreNav.menuA.xmlRoot);
	//window.open("javascript:document.write(opener.coreNav.menuA.htmlString)",
	//'testWin');

	/* Run routine to insert HTML code string into menuA container. */
	var menuA_Container = document.getElementById("menuA");
	insertHtml(coreNav.menuA.htmlString, menuA_Container);

//***** TREE MENU CODE - START *************************************

	/* Create XML fragment used to build dropdown menu item tree and
		establish a "navtree" root within it. */
	coreNav.trayA.xmlDocument = createXMLFromString(
		'<?xml version="1.0" encoding="iso-8859-1"?><navtree></navtree>');
	coreNav.trayA.xmlRoot = coreNav.trayA.xmlDocument.documentElement;

	/* Run the routine that copies nodes from the master XML document to the
	   tree menu XML fragment. The coreNav.trayA.topLevelNodes array is passed
	   in as a parameter to provide the list of nodes to be included in this
	   display group (coreNav.trayA.topLevelNodes is loaded in nav.js). */
	buildTopLevelItems(coreNav.trayA.topLevelNodes, coreNav.trayA.xmlRoot, coreNav);

	/* Create a map of the XML fragment to be used by the getNodeById() funciton. */
	coreNav.trayA.xmlNodeMap = new Object();
	mapXMLTree(coreNav.trayA.xmlRoot, coreNav.trayA.xmlNodeMap);
	//DEBUG_displayNodeMap(coreNav.trayA.xmlNodeMap);

	/* Ensure that the htmlString variable is empty before generating menu code. */
	coreNav.trayA.htmlString = "";

	/* Run the routine that recursively generates HTML code from the dropdown
	   menu XML fragment. */
	coreNav.trayA.buildHtmlStringFromXml(coreNav.trayA.xmlRoot);

	//top.contentFrame.document.write(coreNav.trayA.htmlString);
	//top.contentFrame.document.close();

	/* Run the function that inserts the HTML code string into the menuA
	   container.  Note: this was broken out as a separate function to allow the
	   leftNavWindow document time to load. */
	loadNavTree();

	if ((its.mozilla || its.nn) && its.rv < 1.4)
	{
		/* Display adjustment for early versions of NN7/Moz1 */
		adjustTrayContainers();	
	}


	//***** CODE TO POPULATE ADD'L DISPLAY CONTAINERS ****************

	var quickSearchContainer = document.getElementById("quickSearchCell");
	insertHtml(quickSearchFormHtmlCode(coreNav), quickSearchContainer);

	var menuBarExtrasContainer = document.getElementById("menuBarExtrasCell");
	insertHtml(menuBarExtrasHtmlCode(), menuBarExtrasContainer);
}


function loadNavTree()
{
	if (leftNavWindow == null)
	{
		return;
	}
	
	var topMenuContainer = leftNavWindow.document.getElementById("tree_menu");
	if (topMenuContainer)
	{
		insertHtml(coreNav.trayA.htmlString, topMenuContainer);
	}
	else
	{
		setTimeout("loadNavTree()", 100);
	}
}


function buildTopLevelItems(idList, XMLRoot, navBuilder)
{
	var nodeCopy;
	for (var i=0; i<idList.length; i++)
	{
		if (navBuilder.getNodeById(idList[i]))
		{
			nodeCopy = navBuilder.getNodeById(idList[i]).cloneNode(true);
			XMLRoot.appendChild(nodeCopy);
		}
	}
}


/* MENU_A DISPLAY CODE ****************************************************/
/**************************************************************************/

function menuA_MenuItem_OpeningHtml(node, nodeLocation)
{
	var id = "menuA_" + nodeLocation;

	if (node.tagName == "navtree") // Top-level horizontal menu listing
	{
		this.htmlString +=
			'<table border="0" cellpadding="0" cellspacing="0">\n' +
			'<tr>\n';
	}
	else
	{
		var prefix = "Sub";
		if (node.parentNode.tagName == "navtree") // First-tier child menus
			prefix = "Top";
		
		/* Only create the parent container if it doesn't already exist. */
		if (!node.getAttribute("isRebuild"))
		{	
			this.htmlString +=
				'<div id="' + id + '_menu" class="menuA_' + prefix + 'ChildCollectionContainer" style="display:none">\n' +
				'	<div class="menuA_' + prefix + 'ChildCollectionOutline">\n';
		}
		this.htmlString +=
			'		<table class="menuA_' + prefix + 'ChildListTable" border="0" cellpadding="0" cellspacing="0">\n' +
			'			<tr><td><img src="' + src_tree_space + '" width="1" height="2"></td></tr>\n';

	}
}


function menuA_MenuItem_CoreHtml(node, nodeLocation)
{
	var labelString;
	var linkTarget = node.getAttribute("target");
	var label = node.getAttribute("label");
	var url = node.getAttribute("url");
	var id = "menuA_" + nodeLocation;

	if (node.parentNode.tagName == "navtree") // Top-level menu items
	{
		if (node.tagName == "item")
		{
			/* Generate target attribute code for the <a> tag if a target attribute exists in the XML. */
			if (linkTarget == null || linkTarget == "")
				linkTarget = "contentFrame";

			this.htmlString +=
				'<td id="' + id + '" class="menuA_TopLinkItem" nowrap onclick="linkItem_onclick(event, this)" onmouseover="linkItem_mouseover(this)" onmouseout="linkItem_mouseout(this)">\n' +
				'	<a class="menuA_TopLinkText" href="'+url+'" target="'+linkTarget+'">' + label + '</a>\n' +
				'</td>\n';
		}

		else if (node.tagName == "collection")
		{
			this.htmlString +=
				'<td id="' + id + '" onclick="topCollectionItem_onclick(event, this, \''+id+'_menu\', \'vertical\')" onmouseover="topCollectionItem_mouseover(event, this)" onmouseout="topCollectionItem_mouseout(event, this)">\n' +
				'	<table id="' + id + '_itemTable" class="menuA_TopCollectionItemTable" border="0" cellpadding="0" cellspacing="0">\n' +
				'		<tr>\n' +
				'			<td id="' + id + '_arrowCell" class="menuA_TopCollectionItemArrowCell">\n' +
				'				<img id="' + id + '_arrowImg" src="' + menuA_arrowDownImage + '" width="' + arrowDownImageWidth + '" height="' + arrowDownImageHeight + '"></td>\n' +
				'			<td id="' + id + '_labelCell" class="menuA_TopCollectionItem" nowrap>\n' +
				'				' + label + '</td>\n' +
				'		</tr>\n' +
				'	</table>\n';
		}

	}
	else // Child menu items
	{
		if (node.tagName == "item")
		{
			/* Generate target attribute code for the <a> tag if a target attribute exists in the XML. */
			if (linkTarget == null || linkTarget == "")
				linkTarget = "contentFrame";

			this.htmlString +=
				'<tr>\n' +
				'	<td id="' + id + '" class="menuA_ChildLinkItem" nowrap onclick="linkItem_onclick(event, this)" onmouseover="linkItem_mouseover(this)" onmouseout="linkItem_mouseout(this)">\n' +
				'	<a class="menuA_ChildLinkText" href="'+url+'" target="'+linkTarget+'">' + label + '</a>\n'+
				'	</td>\n' +
				'</tr>\n';
		}

		else if (node.tagName == "collection")
		{
			this.htmlString +=
				'<tr>\n' +
				'	<td id="' + id + '" onclick="childCollectionItem_onclick(event, this, \''+id+'_menu\')" onmouseover="childCollectionItem_mouseover(event, this)" onmouseout="childCollectionItem_mouseout(event, this)">\n' +
				'		<table id="' + id + '_itemTable" class="menuA_ChildCollectionItemTable" style="width:100%" border="0" cellpadding="0" cellspacing="0">\n' +
				'			<tr>\n' +
				'				<td id="' + id + '_labelCell" class="menuA_ChildCollectionItem" nowrap>\n' +
				'					' + label + '</td>\n' +
				'				<td id="' + id + '_arrowCell" class="menuA_ChildCollectionItemArrowCell">\n' +
				'					<img id="' + id + '_arrowImg" src="' + menuA_arrowRightImage + '" width="' + arrowRightImageWidth + '" height="' + arrowRightImageHeight + '"></td>\n' +
				'			</tr>\n' +
				'		</table>\n';
		}
	}
}


function menuA_MenuItem_ClosingHtml(node, nodeLocation)
{
	if (node.tagName == "navtree") // Top-level horizontal menu listing
	{
		this.htmlString +=
			'	</tr>\n' +
			'</table>\n';
	}

	else 
	{
		this.htmlString +=
			'				<tr>\n' +
			'					<td>\n' +
			'						<img src="' + src_tree_space + '" width="1" height="2"></td>\n' +
			'				</tr>\n' +
			'			</table>\n' +
			'		</div>\n' +
			'	 </div>\n' +
			'</td>\n'; // Closing tag for parent cell
		
		if (node.parentNode.tagName != "navtree") // First-tier child menus
			this.htmlString += '</tr>\n';
	}
}

function quickSearchFormHtmlCode(navBuilder)
{
	var htmlString = quickSearchForm;
	htmlString = htmlString.replace(/_self/, "contentFrame");
	return htmlString;
}


function menuBarExtrasHtmlCode()
{
	var htmlString = "";

	htmlString +=
		'							<table align="right" border="0" cellpadding="0" cellspacing="0">\n' +
		'								<tr>\n';

	if (its.ie) // The addBookmark function only works with IE.
	{
		htmlString +=
			'									<td class="menuA_TopMenuBarExtraLink" onclick="addBookmark()" onmouseover="this.className=\'menuA_TopMenuBarExtraLink_over\'" onmouseout="this.className=\'menuA_TopMenuBarExtraLink\'">\n' +
			'										'+lc('wwAddToFavorites')+'</td>\n';
	}

	htmlString +=
		'									<td class="menuA_TopMenuBarExtraLink" onclick="window.contentFrame.location.reload(true)" onmouseover="this.className=\'menuA_TopMenuBarExtraLink_over\'" onmouseout="this.className=\'menuA_TopMenuBarExtraLink\'">\n' +
		'										'+lc('wwRefresh')+'</td>\n';
		'								</tr>\n' +
		'							</table>\n';

	return htmlString;
}


/* This function allows a bookmark to be added relative to the content document in a frameset.*/
function addBookmark()
{
	if (its.ie) // Make sure routine is only run by IE (not supported by other browsers).
	{
		contentUrl = String(window.contentFrame.location); // Had to be converted to String ob before applying RegExp replace function.
		contentUrl = contentUrl.replace(/&coreContentOnly=1/, ""); // Remove coreContentOnly parameter to ensure navshell loads when page is recalled.
		var contentTitle = contentUrl;
		try
		{
			// When the contentFrame is examining a Word doc or PDF, this throws an exception.
			contentTitle = window.contentFrame.document.title;
		}
		catch (e)
		{
		}
		window.external.AddFavorite(contentUrl, contentTitle); // AddFavorite() is an IE-only method.
	}
}


/* Set global click event handler that's used to close menus when a user clicks anywhere
	outside of the menu objects. */
if (window.name == "contentFrame")
{
	var resetFunction = "parent.resetMenus";
}
else
{
	var resetFunction = "resetMenus";
}

document.onclick = eval(resetFunction);



/* LEFT NAV TREE DISPLAY CODE ********************************************/
/*************************************************************************/

/* This function is passed as a parameter to the buildHtmlStringFromXml method.
   It generates the opening html code for a single display collection/folder in
   the nav tree. */
function trayA_Item_OpeningHtml(node, nodeLocation)
{
	if (node.tagName == "navtree") // ROOT-LEVEL (Tray table)
	{
		if (useTrays)
		{
			this.htmlString += '<table id="trayTable" class="trayA_topLevelTable" ' +
				' border="0" cellspacing="0" cellpadding="0">\n';
		}
		else
		{
			this.htmlString +=
				'<table id="trayTable" class="trayA_topLevelTable" border="0"' +
				'	cellspacing="0" cellpadding="0">\n' +
				'	<tr>\n' +
				'		<td style="vertical-align:top;height:100%;width:100%">\n' +
				'			<div id="trayTableMainDiv" ' +
				'style="width:100%;height:100%;padding-left:5px;overflow:auto">\n';
		}
	}
	else if (node.parentNode.tagName == "navtree" && useTrays == true) // TRAY-LEVEL
	{
		if (leftNavWindow != null &&
			leftNavWindow.document.getElementById(node.getAttribute("id")) == null)
		{
			/* If the node contains a tray_doc attribute, an IFrame is loaded
			   into the container rather than menu items; the tray_doc attribute
			   contains the URL that's used to load the IFrame. */
			var trayDoc = node.getAttribute("tray_doc");
			if (trayDoc != null && trayDoc != "")
			{
				this.htmlString +=
				'  <tr>\n' +
				'    <td id="trayA_' + nodeLocation + '_cell" colspan="2" class="trayA_cell_closed">\n' +
				' 		 <table style="width:100%;height:100%;overflow:hidden;table-layout:fixed" border="0" cellpadding="0" cellspacing="0"><tr><td style="white-space:nowrap" nowrap>\n' +
				'				 <div id="trayA_' + nodeLocation + '_scrollBox" class="trayA_scrollBox" style="width:100%;height:1px;display:none;overflow:hidden">\n' +
				'					 <div id="' + node.getAttribute("id") + '" class="trayA_content">\n' +
				'						 <iframe name="' + node.getAttribute("id") + '_iframe" id="' + node.getAttribute("id") + '_iframe" style="width:100%;height:100%" frameborder="0" scrolling="no" src="'+trayDoc+'">\n' +
				'						 </iframe>\n';
			}
			else
			/* This is a normal tray that just contains a node listing. */
			{
				this.htmlString +=
				'  <tr>\n' +
				'    <td id="trayA_' + nodeLocation + '_cell" colspan="2" class="trayA_cell_closed">\n' +
				' 		 <table style="width:100%;height:100%;overflow:hidden;table-layout:fixed" border="0" cellpadding="0" cellspacing="0"><tr><td style="white-space:nowrap" nowrap>\n' +
				'				 <div id="trayA_' + nodeLocation + '_scrollBox" class="trayA_scrollBox" style="width:100%;height:1px;display:none;overflow:auto">\n' +
				'					 <div id="' + node.getAttribute("id") + '" class="trayA_content">\n';
			}
		}
	}
	else // SUB-TRAY-LEVELS
	{
		/* Only create the parent container if it doesn't already exist. */
		if (leftNavWindow.document.getElementById(node.getAttribute("id")) == null)
		{
			this.htmlString += '<div id="' + node.getAttribute("id") + 
				'" style="display:none">\n';
		}
	}
}


/* This function is passed as a parameter to the buildHtmlStringFromXml method.
   It generates the core html code for a single display item in the nav tree.*/
function trayA_Item_CoreHtml(node, nodeLocation)
{
	if (node.parentNode != null &&
		node.parentNode.tagName == "navtree" && useTrays == true) //** TRAY-LEVEL
	{
		this.htmlString +=
			'  <tr>\n' +
			'    <td id="trayA_' + nodeLocation + '_header" class="trayA_header" nowrap>\n' +
			' 		 <table style="width:100%;overflow:hidden;table-layout:fixed" border="0" cellpadding="0" cellspacing="0"><tr><td style="white-space:nowrap" nowrap>\n' +
			'				 <a class="trayA_headerLink_closed" href="javascript:parent.toggleTrayDisplay(\'' + node.getAttribute("id") + '\')" target="_self">\n' +
			'					 <img src="' + trayA_ArrowRight + '" width="9" height="9" border="0"><span style="padding-left:3px">' + node.getAttribute("label") + '</span></a></td></tr></table></td>\n' +
			'    <td style="width:30px"><img src="' + trayA_TrayCorner + '" width="30" height="18" border="0"></td>\n' +
			'  </tr>\n';
	}
	else //** SUB-TRAY-LEVELS
	{
		/* Declare string variables for markup. */
		var iconImageHtml = "";
		var connectorImageHtml = "";
		var offsetImagesHtml = "";
		var imageCellWidth = 0;
		var labelTextHtml = "";
		var id = nodeLocation;

		// **** COLLECTION ****
		if (node.tagName == "collection")
		{
			/* Define icon image and image attributes for current element. */
			if (node.getAttribute("icon"))
			{
				var iconSrc = httpSkinRoot + node.getAttribute("icon");
			}
			else
			{
				var iconSrc = src_Icon_ColClosed;
			}
			var iconWidth = iconWidth_Col;
			var iconHeight = iconHeight_Col;

			/* This block tests any top-level collections to see if they are
			   the first collection in the listing (e.g. they have no previous
			   sibling in their display group).  This is used below to define
			   the unique connector images used for the top collection. */
			var isFirstMenuItem = false;
			if (useTrays)
			{
				if (node.parentNode.parentNode.tagName == "navtree" &&
						previousSiblingElement(node) == null)
				{
					isFirstMenuItem = true;
				}
			}
			else
			{
				if (node.parentNode.tagName == "navtree" &&
					previousSiblingElement(node) == null)
				{
					isFirstMenuItem = true;
				}
			}

			/* Define connector image for the current collection. */
			if (isFirstMenuItem)
			{
				if (nextSiblingElement(node) == null)
				{
					var connectorSrc = src_TopOnly_ColClosed;
				}
				else
				{
					var connectorSrc = src_Top_ColClosed;
				}
			}
			else if (nextSiblingElement(node) != null)
			{
				var connectorSrc = src_T_ColClosed;
			}
			else
			{
				var connectorSrc = src_L_ColClosed;
			}
		}

		// **** ITEM ****
		else
		{
			/* Define icon image and image attributes for current element. */
			if (node.getAttribute("icon"))
			{
				var iconSrc = httpSkinRoot + node.getAttribute("icon");
			}
			else
			{
				var iconSrc = src_Icon_Item;
			}
			var iconWidth = iconWidth_Item;
			var iconHeight = iconHeight_Item;

			/* This block tests any top-level items to see if they are the
			   first item in the listing (e.g. they have no previous sibling in
			   their display group).  This is used below to define the unique
			   connector images used for the top item. */
			var isFirstMenuItem = false;
			if (useTrays)
			{
				if (node.parentNode != null && node.parentNode.parentNode != null &&
					node.parentNode.parentNode.tagName == "navtree" &&
					previousSiblingElement(node) == null)
				{
					isFirstMenuItem = true;
				}
			}
			else
			{
				if (node.parentNode != null &&
					node.parentNode.tagName == "navtree" &&
					previousSiblingElement(node) == null)
				{
					isFirstMenuItem = true;
				}
			}

			/* Define connector image for the current item. */
			if (isFirstMenuItem)
			{
				if (nextSiblingElement(node) == null)
				{
					var connectorSrc = src_TopOnly_Item;
				}
				else
				{
					var connectorSrc = src_Top_Item;
				}
			}
			else if (nextSiblingElement(node) != null)
			{
				var connectorSrc = src_T_Item;
			}
			else
			{
				var connectorSrc = src_L_Item;
			}
		}

		/* Generate the html code for the icon and node-connection point
		   graphics using image property values determined in the block above.
		 */
		iconImageHtml = imageHtml(iconSrc, iconWidth, iconHeight);
		connectorImageHtml = imageHtml(connectorSrc, connectorWidth, connectorHeight);

		/* Loop upward through the ancestors of the current element to generate
		   html code for the offset image graphics (either dotted lines or
		   spaces in this implementation).  Also keep a count of the number of
		   levels to use in calculating the width of the table cell that will
		   contain the images. */
		var parent = node.parentNode;
		var offsetCount = 0;
		var referenceParent;
		while (parent != null && parent.tagName != "navtree")
		{
			if (useTrays)
			{
				referenceParent = parent.parentNode;
			}
			else
			{
				referenceParent = parent;
			}

			if (nextSiblingElement(parent) && referenceParent.tagName != "navtree")
			{
				offsetImagesHtml = 
					imageHtml(src_I, connectorWidth, connectorHeight) +
					offsetImagesHtml;
			}
			else
			{
				offsetImagesHtml = 
					imageHtml(src_tree_space, connectorWidth, connectorHeight) +
					offsetImagesHtml;
			}
			offsetCount++;
			parent = parent.parentNode;
		}

		/* Calculate the width of the table cell containing the images. First
		   the total width of all offset images is calculated, then the widths
		   of the node point connector and the icon are added. */
		imageCellWidth = (offsetCount * connectorWidth) +
						parseInt(connectorWidth) + parseInt(iconWidth);

		/* Generate target attribute code for the <a> tag (if a target
		   attribute exists in the XML). */
		if (node.getAttribute("target") != null && node.getAttribute("target") != "")
		{
			var linkTarget = ' target="' + node.getAttribute("target") + '"';
		}
		else
		{
			var linkTarget = "";
		}

		/* Generate html code for the node point connector and icon graphics
		   and associated links.  In this implementation, the icon for an "item"
		   will be a link to the url from the item's xml "url" attribute; a
		   "collection" will have both the node point connector and icon
		   contained in a common <span> tag with an onclick event that calls the
		   function to open the collection folder. */
		if (node.tagName == "item")
		{
			var nodeImagesHtml = connectorImageHtml + '<a href="' +
						node.getAttribute("url") + '"' + linkTarget + '>' +
						iconImageHtml + '</a>';
		}

		else
		{
			var collectionService = node.getAttribute("collection_service");
			var nodeImagesHtml = '<a id="' + node.getAttribute("id") +
				'_link" onClick="parent.toggleDisplay(\'' + 
				node.getAttribute("id") + '\', \'' + collectionService +
				'\', \'leftNavWindow\')">' + connectorImageHtml + iconImageHtml +
				'</a>';
		}

		/* Generate the html code for the label text. A link will be included
		   if the xml data contains a value for the "url" atrribute (either
		   "items" or "collections" may contain a link). */
		if (node.getAttribute("url") != null && node.getAttribute("url") != "")
		{
			/* This branch had to be added because the addition of the mini
			   search page in the tray in the left menu area seemed to confuse
			   the link targeting mechanisms.  */
			if (linkTarget == "" || linkTarget == "contentFrame")
			{
				labelTextHtml = '<a href="' + node.getAttribute("url") +
					'" class="navItemLink"' + linkTarget + '>' +
					node.getAttribute("label") + '</a>';
			}
			else
			{
				labelTextHtml = '<a href="' + node.getAttribute("url") +
					'" class="navItemLink"' + linkTarget + '>' +
					node.getAttribute("label") + '</a>';
			}
		}
		else
		{
			labelTextHtml = node.getAttribute("label");
		}

		/* Append the final html table code for the item to the global html
		   string variable. */
		this.htmlString +=
			'<table id="' + id + '" class="navItemTable" border="0" cellspacing="0" cellpadding="0">\n' +
			'	<tr>\n' +
			'		<td style="width:' + imageCellWidth.toString() + 'px; text-align:left; white-space:nowrap" nowrap>' + offsetImagesHtml + nodeImagesHtml + '</td>\n' +
			'		<td class="navItemText" nowrap>' + labelTextHtml + '</td>\n' +
			'	</tr>\n' +
			'</table>\n';
	}
}


/* This function is passed as a parameter to the buildHtmlStringFromXml method.
   It generates the closing html code for a single display collection/folder in
   the nav tree. */
function trayA_Item_ClosingHtml(node, nodeLocation)
{
	/* Generate closing <div> tag or tray table closing code for current
	   element (only if parent container didn't exist initially). */
	if (typeof leftNavWindow != "undefined" &&
		leftNavWindow.document.getElementById(node.getAttribute("id")) == null)
	{
		if (node.tagName == "navtree") // ROOT-LEVEL (Left nav table)
		{
			if (useTrays)
			{
				this.htmlString +=
					'  <tr>\n' +
					'    <td id="trayA_buffer" colspan="2" class="trayA_buffer" style="height:auto">\n' +
					'			<div style="height:100%"><img src="' + src_space + '" width="1" height="1"></div></td>\n' +
					'  </tr>\n' +
					'</table>\n';
			}
			else
			{
				this.htmlString +=
					'  		</div>\n' +
					'  	</td>\n' +
					'  </tr>\n' +
					'</table>\n';
			}
		}
		else if (node.parentNode.tagName == "navtree" && useTrays == true)
		{
			// TRAY-LEVEL
			this.htmlString +=
				'							</div>\n' +
				'						</div>\n' +
				'					</td>\n' +
				'				</tr>\n' +
				'			</table>\n' +
				'		</td>\n' +
				'  </tr>\n';
		}
		else
		{
			this.htmlString += '</div>\n';
		}
	}
}



/* LEFT NAV TREE DHTML ************************************************/
/**********************************************************************/

/* Initialize count variable. */
var openTrayCount = 0;
var openTrayId = "";

function toggleTrayDisplay(nodeId)
{
	var trayContainer = leftNavWindow.document.getElementById(nodeId);
	var trayBuffer = leftNavWindow.document.getElementById("trayA_buffer");
	var parentOb = trayContainer;
	var trayScrollBox, trayCell;

	while (parentOb.id != "trayTable")
	{
		if (parentOb.id.indexOf("scrollBox") != -1) { trayScrollBox = parentOb; }
		else if (parentOb.id.indexOf("cell") != -1) { trayCell = parentOb; }
		parentOb = parentOb.parentNode;
	}
	
	var trayId = trayScrollBox.id.split("_")[1];
	var trayHeader = leftNavWindow.document.getElementById("trayA_" + trayId + "_header");
	var trayHeaderLink = trayHeader.getElementsByTagName("A")[0];
	var trayArrowImage = trayHeader.getElementsByTagName("IMG")[0];
	if (trayCell.className == "trayA_cell_closed")
	{
		if (nodeId == openTrayId)
		{
			// We have gotten into a bad state, probably through a refresh of the navigation pane,
			// where we are trying to close a tray which is already closed.  Fix the javascript
			// variables and return.
			
			openTrayCount--;
			if (allowMultipleTrays == false)
			{
				openTrayId = "";
			}
			return;
		}
	
		// close currently open tray, if any
		if (allowMultipleTrays == false)
		{
			if (openTrayId != "")
			{
				toggleTrayDisplay(openTrayId);
			}
			openTrayId = nodeId;
		}
		
		// Safari workaround: set the size of the new tray to the size of the current open space
		var trayBufferDims = new top.dimensionFinder(trayBuffer);
		var trayScrollBoxHeight = trayBufferDims.height;
		//trayScrollBox.style.height = "100%";
		trayScrollBox.style.height = trayScrollBoxHeight;

		trayScrollBox.style.display = "block";
		trayCell.className = "trayA_cell_open";
		trayHeaderLink.className = "trayA_headerLink_open";
		trayArrowImage.src = trayA_ArrowDown;
		openTrayCount++;

		/* Declare variables used to reference XML node in order to get attribute values. */
		var xmlNode = coreNav.trayA.getNodeById(nodeId);

		/* Declare variable used to determine value (and/or existence) of collection service. In this
			implementation, collection service is used to dynamically generate and insert child nodes
			for collections in the Library (index) sub-tree (for nodes that don't have a collection
			service, their child nodes were generated at the time the page is initially loaded). */
		var collectionService = xmlNode.getAttribute("collection_service");

		/* Declare variable to determine value (and/or existence) of tray_doc attribute. In cases where
			a tray contains an IFrame used to load a separate document (such as the Search tray), the
			tray_doc attribute provides the URL of the document to be loaded when the tray is opened. */
		var trayDoc = xmlNode.getAttribute("tray_doc");

		if (collectionService && trayContainer.getElementsByTagName("table").length == 0)
		/* Run the collection service routines only if the child nodes haven't been loaded already
			(e.g. the <div> container doesn't already contain any <table> code). */
		{
			if (collectionService.indexOf("javascript:") == 0)
			/* This conditional was added to allow use with Javascript-based collection services.
				This is included to enable a broader range of customization; it isn't currently used
				in this implementation. */
			{
				jsLoadFunction = collectionService.split(":")[1];
				eval(jsLoadFunction);
			}
			else
			{
				/* Load hidden frame with lm_dir_page.htm template. The onload event of this page calls the
				parseChildNodesXml() function. This can potentially be used with other services for different
				customizations.*/
				hiddenActionWindow.location.replace(collectionService);
			}
			/* Note: the code that displays the container is located in the collection service-related functions.*/
		}

		else if (xmlNode.getAttribute("tray_doc"))
		/* If the current node has a tray_doc attribute, load that URL into the corresponding iframe for that
			node (if the frame hasn't been loaded already).  */
		{
			var trayIframe = leftNavWindow.document.getElementById(trayContainer.id + "_iframe");
			if (trayIframe.src == null || trayIframe.src == "" || trayIframe.src == blankPageUrl ||
			    typeof(trayIframe.contentDocument) == "undefined" ||
			    typeof(trayIframe.contentDocument.body) == "undefined" ||
			    typeof(trayIframe.contentDocument.body.innerHTML) == "undefined" ||
			    trayIframe.contentDocument.body.innerHTML.length == 0)
			{
				trayIframe.src = xmlNode.getAttribute("tray_doc");
			}
		}
	}

	else
	{
		trayScrollBox.style.display = "none";
		trayScrollBox.style.height = "1px";
		trayCell.className = "trayA_cell_closed";
		trayHeaderLink.className = "trayA_headerLink_closed";
		trayArrowImage.src = trayA_ArrowRight;
		openTrayCount--;

		if (allowMultipleTrays == false)
		{
			openTrayId = "";
		}
	}

	if (openTrayCount == 0) trayBuffer.style.height = "auto";
	else trayBuffer.style.height = "1px";

	if (its.mozilla || its.nn || its.safari)
	/* Display adjustment for early versions of NN7/Moz1*/
	{
		dynamicTrayAdjustInit();
	}
}

/* Another Netscape display fix function. This one is used with the onresize event; for
	some reason the div containers must first be collapsed down to a small size (1px) before
	firing the adjustTrayContainers() function to force them to match the size of the parent
	cell. Note: Safari and IE also need this, now that the resize logic is different in post 7.5*/
function dynamicTrayAdjustInit()
{
	if (typeof leftNavWindow == "undefined")
		return;
		
	var i = 0;
	var trayCell = leftNavWindow.document.getElementById("trayA_" + i + "_cell");
	var trayScrollBox = leftNavWindow.document.getElementById("trayA_" + i + "_scrollBox");

	while (trayCell != null)
	{
		if (trayCell.className.indexOf("_open") != -1)
		{
			trayScrollBox.style.height = "1px";
		}
		i++;
		trayCell = leftNavWindow.document.getElementById("trayA_" + i + "_cell");
		trayScrollBox = leftNavWindow.document.getElementById("trayA_" + i + "_scrollBox");
	}
	adjustTrayContainers();
}
if (parent.dynamicTrayAdjustInit && !coreContentOnly)
{
	window.onresize = parent.dynamicTrayAdjustInit;
}


/* This function fixes a Netscape display problem. It goes through the tray container
	div tags and forces their height to match that of the parent cell (for some reason
	the 100% height attribute doesn't work when the parent cell is set to "auto".)*/
function adjustTrayContainers()
{
	/* This sizes the tray table to match the height of the left nav cell */
	if (document.getElementById("leftNavCell") != null && leftNavWindow.document.getElementById("trayTable") != null)
	{
		var leftNavCell = document.getElementById("leftNavCell");
		var trayTable = leftNavWindow.document.getElementById("trayTable");
		trayTable.style.height = leftNavCell.offsetHeight;
	}

	var i = 0;
	var trayCell = leftNavWindow.document.getElementById("trayA_" + i + "_cell");
	var trayScrollBox = leftNavWindow.document.getElementById("trayA_" + i + "_scrollBox");
	var trayBuffer = leftNavWindow.document.getElementById("trayA_buffer");
	var trayBufferDims = new top.dimensionFinder(trayBuffer);
	var trayScrollBoxHeight = trayBufferDims.height;
	/* These loops will probably have to be adjusted to walk through an XML fragment
		and find containers based upon ID values.*/
	while (trayCell != null)
	{
		if (trayCell.className.indexOf("_open") != -1)
		{
			if (its.safari)
				trayScrollBox.style.height = trayScrollBoxHeight
			else
				trayScrollBox.style.height = trayScrollBox.offsetParent.offsetHeight;
			trayScrollBox.style.display = "block";
		}
		i++;
		trayCell = leftNavWindow.document.getElementById("trayA_" + i + "_cell");
		trayScrollBox = leftNavWindow.document.getElementById("trayA_" + i + "_scrollBox");
	}
}


/**** LIBRARY CODE */
var libNavBuilder = null;
/* This function is called from the lm_dir_page.htm template (this template gets loaded into
	a hidden Iframe (hiddenActionWindow) and populates the tempNavBuilder XML object with nodes
	when the user opens a library folder).*/
function libraryNodeLoadSequence(tempNavBuilder)
{
	if (tempNavBuilder)
		libNavBuilder = tempNavBuilder;

	var childNodesXmlRoot = libNavBuilder.xmlDocument.getElementsByTagName("navtree")[0];

	if (childNodesXmlRoot != null)
	{
		/* Set object variables to be used as parameters of the insertParsedChildNodes()
			and generateChildNodeDisplayCode() funcitons. */
		var childNodeList = childNodesXmlRoot.childNodes;
		var parentId = childNodesXmlRoot.getAttribute("page_name");
		var parentNode = coreNav.trayA.getNodeById(parentId);
		var parentHtmlContainer = leftNavWindow.document.getElementById(parentId);

		insertParsedChildNodes(coreNav.trayA, childNodeList, parentNode, "replace");

		if (generateChildNodeDisplayCode(coreNav.trayA, parentNode, parentHtmlContainer))
		/* Change the display of the container only if nodes were actually added to it. */
		{
			parentHtmlContainer.style.display = "block";
		}
		else
		{
			parentHtmlContainer.style.display = "none";
		}
	}
	else
	{
		setTimeout("libraryNodeLoadSequence()", 100);
	}
}

/**** ADD DOCUMENT PROFILE CODE */
/* This function is called during user profile editing when a user updates
   the list of profile that should be made available on the navigation links. */
function updateDocProfilesNav(checkinList, checkinUrlList, searchList, searchUrlList)
{
	var tempCheckinNavBuilder = new navBuilder();
	var tempSearchNavBuilder = new navBuilder();

	for (var i = 0; i < checkinList.length; i++)
	{
		// Encode XML escape character entities.
		var titleString = xmlEncode(checkinList[i]);
		var urlString = xmlEncode(checkinUrlList[i]);

		tempCheckinNavBuilder.addChildNodeTo('NAVTREE', 'item', 'id==PERSONAL_DOC_PROFILE_CHECKIN_'+(i+1), 'label=='+titleString,
			'url=='+urlString, 'target==contentFrame');
	}
	
	for (var i = 0; i < searchList.length; i++)
	{
		// Encode XML escape character entities.
		var titleString = xmlEncode(searchList[i]);
		var urlString = xmlEncode(searchUrlList[i]);

		tempSearchNavBuilder.addChildNodeTo('NAVTREE', 'item', 'id==PERSONAL_DOC_PROFILE_SEARCH_'+(i+1), 'label=='+titleString,
			'url=='+urlString, 'target==contentFrame');
	}

    // perform last-minute customization, then draw the check-in nodes
    if (typeof finishPersonalCheckinLoadSequence != "undefined")
	{
        finishPersonalCheckinLoadSequence(tempCheckinNavBuilder);
	}
    personalCheckinLoadSequence(tempCheckinNavBuilder);

    // perform last-minute customization, then draw the search nodes
    if (typeof finishPersonalSearchLoadSequence != "undefined")
	{
        finishPersonalSearchLoadSequence(tempSearchNavBuilder);
	}
    personalSearchLoadSequence(tempSearchNavBuilder);
}

var pneCheckinNavBuilder = null;
function personalCheckinLoadSequence(tempNavBuilder)
{
    if (tempNavBuilder)
        pneCheckinNavBuilder = tempNavBuilder;

    var childNodesXmlRoot = pneCheckinNavBuilder.xmlDocument.getElementsByTagName("navtree")[0];

    if (childNodesXmlRoot != null)
    {
        /* Set object variables to be used as parameters of the insertParsedChildNodes()
            and generateChildNodeDisplayCode() funcitons. */
        var childNodeList = childNodesXmlRoot.childNodes;
        var parentNode = coreNav.trayA.getNodeById("MY_PERSONAL_CHECKINS");
        if (parentNode)
        {
			var parentHtmlContainer = leftNavWindow.document.getElementById("MY_PERSONAL_CHECKINS");

			/* Run the routines that insert the parsed XML into the appropriate fragment, and
				dynmically modify the html display code. */
			insertParsedChildNodes(coreNav.trayA, childNodeList, parentNode, "replace");
			generateChildNodeDisplayCode(coreNav.trayA, parentNode, parentHtmlContainer);

			/* Set image variable to be used in display-setting block below. */
			var treeConnectorImage = leftNavWindow.document.getElementById("MY_PERSONAL_CHECKINS_link").getElementsByTagName("IMG")[0];

			if (treeConnectorImage.src.indexOf("open.gif") > -1)
			{
				if (childNodeList.length > 0)
				/* If the collection was empty but the user had the folder open, display the html container
					if items were added to the node list by the update. */
				{
					parentHtmlContainer.style.display = "block";
				}
				else if (childNodeList.length == 0)
				/* If the collection previously had contents and the user had the folder open, supress display
					of the html container if all items were removed from the node list by the update. */
				{
					parentHtmlContainer.style.display = "none";
				}
			}
		}
    }
    else
    {
        setTimeout("personalCheckinLoadSequence()", 100);
    }
}

var pneSearchNavBuilder = null;
function personalSearchLoadSequence(tempNavBuilder)
{
    if (tempNavBuilder)
        pneSearchNavBuilder = tempNavBuilder;

    var childNodesXmlRoot = pneSearchNavBuilder.xmlDocument.getElementsByTagName("navtree")[0];

    if (childNodesXmlRoot != null)
    {
        /* Set object variables to be used as parameters of the insertParsedChildNodes()
            and generateChildNodeDisplayCode() funcitons. */
        var childNodeList = childNodesXmlRoot.childNodes;
        var parentNode = coreNav.trayA.getNodeById("MY_PERSONAL_SEARCHES");
        if (parentNode)
        {
			var parentHtmlContainer = leftNavWindow.document.getElementById("MY_PERSONAL_SEARCHES");

			/* Run the routines that insert the parsed XML into the appropriate fragment, and
				dynmically modify the html display code. */
			insertParsedChildNodes(coreNav.trayA, childNodeList, parentNode, "replace");
			generateChildNodeDisplayCode(coreNav.trayA, parentNode, parentHtmlContainer);

			/* Set image variable to be used in display-setting block below. */
			var treeConnectorImage = leftNavWindow.document.getElementById("MY_PERSONAL_SEARCHES_link").getElementsByTagName("IMG")[0];

			if (treeConnectorImage.src.indexOf("open.gif") > -1)
			{
				if (childNodeList.length > 0)
				/* If the collection was empty but the user had the folder open, display the html container
					if items were added to the node list by the update. */
				{
					parentHtmlContainer.style.display = "block";
				}
				else if (childNodeList.length == 0)
				/* If the collection previously had contents and the user had the folder open, supress display
					of the html container if all items were removed from the node list by the update. */
				{
					parentHtmlContainer.style.display = "none";
				}
			}
		}
    }
    else
    {
        setTimeout("personalSearchLoadSequence()", 100);
    }
}

/**** PERSONAL URL UPDATE CODE */
/* This function is conditionally called by the updatePersonalURLS() function in the
	lm_pne_portal_personal_urls_page.htm (located in custom/LayoutManager/templates). */
function updatePersonalUrlTree(titleArray, urlArray)
{
	var tempNavBuilder = new navBuilder();

	for(var i=0; i<titleArray.length; i++)
	{
		var urlString = urlArray[i];
		var titleString = titleArray[i];

		// Encode XML escape character entities.
		titleString = xmlEncode(titleArray[i]);
		urlString = xmlEncode(urlArray[i]);

		tempNavBuilder.addChildNodeTo('NAVTREE', 'item', 'id==PERSONAL_URL_'+(i+1), 'label=='+titleString,
			'url=='+urlString, 'target==_blank');
	}

	personalUrlLoadSequence(tempNavBuilder);
}

var urlNavBuilder = null;
function personalUrlLoadSequence(tempNavBuilder)
{
	if (tempNavBuilder)
		urlNavBuilder = tempNavBuilder;

	var childNodesXmlRoot = urlNavBuilder.xmlDocument.getElementsByTagName("navtree")[0];

	if (childNodesXmlRoot != null)
	{
		/* Set object variables to be used as parameters of the insertParsedChildNodes()
			and generateChildNodeDisplayCode() funcitons. */
		var childNodeList = childNodesXmlRoot.childNodes;
		var parentNode = coreNav.trayA.getNodeById("MY_PERSONAL_URLS");		
		var parentHtmlContainer = leftNavWindow.document.getElementById("MY_PERSONAL_URLS");

		/* Run the routines that insert the parsed XML into the appropriate fragment, and
			dynmically modify the html display code. */
		insertParsedChildNodes(coreNav.trayA, childNodeList, parentNode, "replace");
		generateChildNodeDisplayCode(coreNav.trayA, parentNode, parentHtmlContainer);

		/* Set image variable to be used in display-setting block below. */
		var treeConnectorImage = leftNavWindow.document.getElementById("MY_PERSONAL_URLS_link").getElementsByTagName("IMG")[0];

		if (treeConnectorImage.src.indexOf("open.gif") > -1)
		{
			if (childNodeList.length > 0)
			/* If the collection was empty but the user had the folder open, display the html container
				if items were added to the node list by the update. */
			{
				parentHtmlContainer.style.display = "block";
			}
			else if (childNodeList.length == 0)
			/* If the collection previously had contents and the user had the folder open, supress display
				of the html container if all items were removed from the node list by the update. */
			{
				parentHtmlContainer.style.display = "none";
			}
		}
	}
	else
	{
		setTimeout("personalUrlLoadSequence()", 100);
	}
}


/**** ADD SAVED QUERY CODE */
/* This function is conditionally called by the saveSearchQuery() function in the
	query_form_submit_script include override located in lm_std_page.htm (when the Save
	button is clicked on a search results page). */
function addSavedQueryToTree(qTitle, qUrl)
{
	// Declare variables for use in FOR loop below.
	var savedQueriesParentNode = coreNav.trayA.getNodeById("MY_SAVED_QUERIES");
	var savedQueriesNodeList = savedQueriesParentNode.childNodes;

	// delete the node from the tree if there are too many
	if (savedQueriesNodeList.length >= maxSavedSearchResults)
		coreNav.trayA.deleteItem('MY_SAVED_QUERY_' + maxSavedSearchResults);

	/* Loop upward through the XML node list of saved queries and re-set the ID values by adding
		one to the index number within each. This allows the new query to be added to the top
		of the list with the sequentially-correct ID value of MY_SAVED_QUERY_1. */
	for (var i=savedQueriesNodeList.length-1; i>=0; i--)
	{
		if (savedQueriesNodeList[i].nodeType == 1)
		{
			var idIndexArray = savedQueriesNodeList[i].getAttribute("id").split("_");
			idIndexArray[3] = parseInt(idIndexArray[3]) + 1;
			idIndexArray[3].toString();
			savedQueriesNodeList[i].setAttribute("id", idIndexArray.join("_"));
		}
	}

	// add the new saved query to the list with index 1
	var tempNavBuilder = new navBuilder();
	qTitle = xmlEncode(qTitle);
	qUrl = xmlEncode(qUrl);
	tempNavBuilder.addChildNodeTo('NAVTREE', 'item', 'id==MY_SAVED_QUERY_1', 'label=='+qTitle, 'url=='+qUrl);
	addQueryLoadSequence(tempNavBuilder);
}

var queryNavBuilder = null;
function addQueryLoadSequence(tempNavBuilder)
{
	if (tempNavBuilder)
		queryNavBuilder = tempNavBuilder;

	var childNodesXmlRoot = queryNavBuilder.xmlDocument.getElementsByTagName("navtree")[0];

	if (childNodesXmlRoot != null)
	{
		/* Set object variables to be used as parameters of the insertParsedChildNodes()
			and generateChildNodeDisplayCode() funcitons. */
		var childNodeList = childNodesXmlRoot.childNodes;
		var parentNode = coreNav.trayA.getNodeById("MY_SAVED_QUERIES");
		var parentHtmlContainer = leftNavWindow.document.getElementById("MY_SAVED_QUERIES");

		/* Run the routines that insert the parsed XML into the appropriate fragment, and
			dynmically modify the html display code. */
		insertParsedChildNodes(coreNav.trayA, childNodeList, parentNode, "addToTop");
		generateChildNodeDisplayCode(coreNav.trayA, parentNode, parentHtmlContainer);

		/* Set image variable to be used in display-setting block below. */
		var treeConnectorImage = leftNavWindow.document.getElementById("MY_SAVED_QUERIES_link").getElementsByTagName("IMG")[0];

		if (treeConnectorImage.src.indexOf("open.gif") > -1)
		{
			if (childNodeList.length > 0)
			/* If the collection was empty but the user had the folder open, display the html container
				if items were added to the node list by the update. */
			{
				parentHtmlContainer.style.display = "block";
			}
			else if (childNodeList.length == 0)
			/* If the collection previously had contents and the user had the folder open, supress display
				of the html container if all items were removed from the node list by the update. */
			{
				parentHtmlContainer.style.display = "none";
			}
		}
	}
	else
	{
		setTimeout("addQueryLoadSequence()", 100);
	}
}


/**** SAVED QUERY UPDATE CODE */
/* This function is conditionally called by the updateSavedQueries() function in the
    lm_pne_portal_saved_queries_page.htm (located in custom/LayoutManager/templates). */
function updateSavedQueriesTree(deleteString)
{
    var deleteItemArray = deleteString.split(",");
    var parentNode = coreNav.trayA.getNodeById("MY_SAVED_QUERIES");
    var parentHtmlContainer = leftNavWindow.document.getElementById("MY_SAVED_QUERIES");
    var savedQueriesNodeList = parentNode.childNodes;

    /* Loop upward through the node list; check each label attribute value against the query
        title values in the deleteItemArray. If a match is found, delete the node from the tree.
        Note: had to loop upward rather than downward since node list contents are dynamic. */
    for (var i=savedQueriesNodeList.length-1; i>=0; i--)
    {
        if (savedQueriesNodeList[i].nodeType == 1)
        {
            var queryTitle = savedQueriesNodeList[i].getAttribute("label");
            for (var j=0; j<deleteItemArray.length; j++)
            {
                if (queryTitle == deleteItemArray[j])
                {
                    parentNode.removeChild(savedQueriesNodeList[i]);
                    break;
                }
            }
        }
    }

    /* Remap the treeMenu fragment after the nodes have been deleted. */
    coreNav.trayA.xmlNodeMap = new Object();
    mapXMLTree(coreNav.trayA.xmlRoot, coreNav.trayA.xmlNodeMap);
    //DEBUG_displayNodeMap(coreNav.trayA.xmlNodeMap);

    /* Run the routine that dynmically modifies the html display code based upon the
        modified tree. */
    generateChildNodeDisplayCode(coreNav.trayA, parentNode, parentHtmlContainer);
}


/* NAVIGATION SHELL DHTML **************************************************************************/
/***************************************************************************************************/


/* This function allows the main page columns to be resized by dragging on the bar between the left
	nav and content areas. An indirect method of resizing is used, where the user drags a floating bar
	to the desired location, and the table then snaps to the new size upon mouseup. This was done to
	prevent the continuous refresh problems associated with dragging and sizing the table cells directly. */
function sizePageColumns(event)
{
	document.body.style.cursor = "e-resize";

	/* Declare object variables */
	var leftCol = document.getElementById("leftNavCell");
	var rightCol = document.getElementById("contentCell");
	var dragBar = document.getElementById("dragBar");
	var frameDividerCell = dragBar.parentNode;
	var pageMask = document.getElementById("pageMask");
	var frameParentCell = pageMask.parentNode;

	/* Make the drag bar object visible, and set its size and position to match those of
		the frame divider cell. */
	dragBar.style.display = "block";
	var frameDividerCellInfo = new dimensionFinder(frameDividerCell);
	dragBar.style.height = frameDividerCellInfo.height;
	dragBar.style.width = frameDividerCellInfo.width;
	dragBar.style.top = frameDividerCellInfo.relativeTop;
	dragBar.style.left = frameDividerCellInfo.relativeLeft;

	/* Place a mask over the page area to prevent iframe documents from taking control
		of events away from the top-level document. */
	pageMask.style.display = "block";
	var frameParentCellInfo = new dimensionFinder(frameParentCell);
	pageMask.style.height = frameParentCellInfo.height;
	pageMask.style.width = frameParentCellInfo.width;
	pageMask.style.top = frameParentCellInfo.relativeTop;
	pageMask.style.left = frameParentCellInfo.relativeLeft;

	// Set the starting X-position of the mouse.
	var startPosX = event.clientX;

	// Register the event handlers that will respond to the mousemove events
	// and the mouseup event that follow this mousedown event.
	if (document.addEventListener)
	{ // DOM Level 2 Event Model
		// (Note: I left the DOM branching in case IE supports these standards in the future).
		document.addEventListener("mousemove", moveHandler, true);
		document.addEventListener("mouseup", upHandler, true);
	}
	else if (document.attachEvent)
	{ // IE 5+ Event Model
		document.attachEvent("onmousemove", moveHandler);
		document.attachEvent("onmouseup", upHandler);
	}

	// We've handled this event.  Don't let anybody else see it.
	if (event.stopPropagation) event.stopPropagation();   // DOM Level 2
	else event.cancelBubble = true;                       // IE

	// Now prevent any default action.
	if (event.preventDefault) event.preventDefault();     // DOM Level 2
	else event.returnValue = false;                       // IE

	/**
	 * This is the handler that captures mousemove events when an element
	 * is being dragged.  It is responsible for moving the element.
	 **/
	function moveHandler(e)
	{
		if (!e) e = window.event;  // IE event model

		var startDragBarPosX = dragBar.offsetLeft;
		var maxDragPosX = document.body.clientWidth - 100;

		// Set new dragBar position based upon cursor location (conditionals limit the max an min drag positions).
		if (startDragBarPosX - (startPosX - e.clientX) > 25 && startDragBarPosX - (startPosX - e.clientX) < maxDragPosX)
		{
			var newDragBarPosX = startDragBarPosX - (startPosX - e.clientX);
			dragBar.style.left = newDragBarPosX + "px";
		}

		// Reset starting mouse position.
		startPosX = e.clientX;

		// And don't let anyone else see this event.
		if (e.stopPropagation) e.stopPropagation();       // DOM Level 2
		else e.cancelBubble = true;                       // IE
	}

	/**
	 * This is the handler that captures the final mouseup event that
	 * occurs at the end of a drag.
	 **/
	function upHandler(e)
	{
		if (!e) e = window.event;  // IE event model

		/* Resize the left table cell based upon the final position of the dragBar. The right cell
		  (content area) should size automatically to take the remaining space in the window. */
		var dragBarEndPosX = dragBar.offsetLeft;
		leftCol.style.width = (dragBarEndPosX) + "px";

		// Unregister the capturing event handlers.
		if (document.removeEventListener)
		{	// DOM Event Model
				document.removeEventListener("mouseup", upHandler, true);
				document.removeEventListener("mousemove", moveHandler, true);
		}
		else if (document.detachEvent)
		{	// IE 5+ Event Model
				document.detachEvent("onmouseup", upHandler);
				document.detachEvent("onmousemove", moveHandler);
		}

		/* Hide the IE mask. */
		pageMask.style.display = "none";

		/* Hide the drag bar object. */
		dragBar.style.display = "none";

		document.body.style.cursor = "auto";

		// And don't let the event propagate any further.
		if (e.stopPropagation) e.stopPropagation();       // DOM Level 2
		else e.cancelBubble = true;                       // IE
	}
}



