<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="html" indent="no"/>
<xsl:strip-space elements="*"/>
	<!--MENU-->
	<xsl:template match="MENU" mode="top">
		<xsl:apply-templates select="MENU-ITEM"  mode="top"/>
	</xsl:template>
 
	<!--MENU-ITEM-->
	<xsl:template match="MENU-ITEM"  mode="top">
	<xsl:variable name="position"><xsl:value-of select="position()" /></xsl:variable>
   		<xsl:choose>
           <!-- when vizited inside-->
           	<xsl:when test="MENU-ITEM[@ID=/LAYOUT/@ID]" >
   				<td><a href="{@HREF}" class="amenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>
    	        <xsl:if test="position()!=last()">
    				<td width="10"></td>
    				<td><img src="images/separator.gif" border="0"/></td>
    				<td width="10"></td>
        	    </xsl:if>
            </xsl:when>
            <!-- when active-->
            <xsl:when test="MENU-ITEM[@ID=/LAYOUT/@ID] or @ID=/LAYOUT/@ID" >
   				<td class="amenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></td>
    	        <xsl:if test="position()!=last()">
    				<td width="10"></td>
    				<td><img src="images/separator.gif" border="0"/></td>
    				<td width="10"></td>
        	    </xsl:if>
            </xsl:when>
            <xsl:otherwise>
   				<td><a href="{@HREF}" class="menu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>
    	        <xsl:if test="position()!=last()">
    				<td width="10"></td>
    				<td><img src="images/separator.gif" border="0"/></td>
    				<td width="10"></td>
        	    </xsl:if>
            </xsl:otherwise>
        </xsl:choose>
	</xsl:template>


	<xsl:template match="MENU-ITEM" mode="sub">
        <xsl:choose>
            <xsl:when test="@ID=/LAYOUT/@ID" >
   				<tr>
   					<td style="text-decoration:underline; padding-left: 7px" height="35" class="submenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></td>
   					<td align="right" style="padding-right: 7px"><img src="images/submenu_bullet.gif"/></td>
   				</tr>							
            </xsl:when>
            <xsl:otherwise>
				<xsl:if test="../MENU-ITEM[@ID=/LAYOUT/@ID] or ../../MENU-ITEM[@ID=/LAYOUT/@ID]">
    				<tr>
    					<td style="padding-left: 7px" height="35"><a href="{@HREF}" class="submenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>
    					<td align="right" style="padding-right: 7px"><a href="{@HREF}"><img src="images/submenu_bullet.gif" border="0"/></a></td>
    				</tr>
				</xsl:if>
            </xsl:otherwise>
		</xsl:choose>
		<xsl:if test="position()!=last()">
			<tr><td colspan="2" height="1" bgcolor="#E1E1E1"></td></tr>
		</xsl:if>
	</xsl:template>



</xsl:stylesheet>
