<?xml version='1.0'?>
<!--Copyright 1999-2003 Intuit Inc. All rights reserved. Unauthorized duplication is a violation of applicable law.-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:script language="JScript">
<![CDATA[
		// get a reference to QB's preferences so we can run some QBOL
	locator = new ActiveXObject("QuickBooks.CoLocator");
	prefs = locator.Create("QBPrefs.Preferences");

		// determine whether the menu item should be visible in the menu
	function isVisible(
		inItemNode) 
	{
			// get the item's visibilityTest, if any
		var visibilityTestNode = inItemNode.selectSingleNode("visibilityTest");

		if (!visibilityTestNode) {
				// when there's no visibilityTest node, we assume the item's always visible
			return true;
		} else {
				// evaluate the QBOL in the visibilityTest node
			return (prefs.QBOL(visibilityTestNode.text) == true);
		}
	}

		// determine whether the page currently displayed in the navigator corresponds 
		// to this menu item 
	function isCurrentPage(
		inItemNode) 
	{
			// get the item's pageName node
		var pageNameNode = inItemNode.selectSingleNode("pageName");

		if (!pageNameNode) {
				// for some reason there's no pageName node, which means the XML is ill-formed
			return false;
		} 

			// covnert the pageName to lowercase
		var pageName = pageNameNode.text;
		pageName = pageName.toLowerCase();

			// the currentPageName is passed in from the JavaScript as an attribute 
			// of the menu node.  
		var menuNode = inItemNode.ownerDocument.selectSingleNode("/menu");
		var currentPageName = menuNode.getAttribute("currentPageName").toString();

			// convert to lowercase so we can compare it to the menu item's pageName.
		currentPageName = currentPageName.toLowerCase();

			// return whether the item should get a checkmark next to it
		return pageName == currentPageName;
	}

]]>
</xsl:script>

<xsl:template match="/">

<table class="navMenu" cellspacing="0" cellpadding="0" 
	onmouseover="navMenu_OnMouseOver(event);" 
	onmouseout="navMenu_OnMouseOut(event);" 
	onclick="navMenu_OnMouseUp(event);" 
	onselectstart="return false;"
>

<xsl:for-each select="menu/items/item">
	<xsl:if expr="isVisible(this)">
		<tr class="navMenuItem">
				<xsl:attribute name="id"><xsl:value-of select="pageName" /></xsl:attribute>
			<td class="navMenuCheckCell"><xsl:if expr="isCurrentPage(this)">a</xsl:if></td>
			<td class="navMenuTitleCell"><xsl:value-of select="title" /></td>
		</tr>
	</xsl:if>
</xsl:for-each>

</table>

</xsl:template>

</xsl:stylesheet>

