<?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>
           <!-- active menu with link-->
           	<xsl:when test="MENU-ITEM[@ID=/LAYOUT/@ID] or @ID=/LAYOUT/@ID">
				<td><img src="images/separator.gif" border="0"/></td>
				<td width="10" style="background-image: url('images/amenu_bg.gif'); background-repeat: repeat-x;"></td>
				<td style="background-image: url('images/amenu_bg.gif'); background-repeat: repeat-x;"><a href="{@HREF}"><img src="images/abullet.gif" border="0"/></a></td>
				<td style="background-image: url('images/amenu_bg.gif'); background-repeat: repeat-x;" width="5"></td>
				<td style="background-image: url('images/amenu_bg.gif'); background-repeat: repeat-x;"><a href="{@HREF}" class="amenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>
				<td width="10" style="background-image: url('images/amenu_bg.gif'); background-repeat: repeat-x;"></td>
            </xsl:when>
            
            
            <xsl:otherwise>				
				<td><a href="{@HREF}"><img src="images/bullet.gif" border="0"/></a></td>
				<td width="5"></td>
				<td><a href="{@HREF}" class="menu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>							
				<td width="10"></td>
            </xsl:otherwise>
	    </xsl:choose>
		<xsl:if test="position()!=last()"> 	
			<xsl:if test="not(../MENU-ITEM[$position+1]/MENU-ITEM[@ID=/LAYOUT/@ID] or ../MENU-ITEM[$position+1][@ID=/LAYOUT/@ID]) and $position != last()">
				<td><img src="images/separator.gif" border="0"/></td>						
				<td width="10"></td>
		  	</xsl:if> 	
	</xsl:if>
	</xsl:template>	

</xsl:stylesheet>
