﻿<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:param name="NavType">LEFT</xsl:param>
    <xsl:output method="html" omit-xml-declaration="yes"/>


    <xsl:template match="/NavNodes">
        <table cellpadding="0" cellspacing="0" class="MSC_PrimaryNavFrame" style="width:auto;">
            <xsl:for-each select="NavNode">
                <xsl:variable name="ChildSelected" select="count(NavNode[@selected='true']) != '0'" />
                <xsl:variable name="SelfOrChildSelected" select="$ChildSelected or (@selected='true')" />
                <tr>
                    <td>
                        <xsl:attribute name="class">
                            <xsl:choose>
                                <xsl:when test="$SelfOrChildSelected">MSC_PrimaryNavLinkFrame-On</xsl:when>
                                <xsl:otherwise>MSC_PrimaryNavLinkFrame</xsl:otherwise>
                            </xsl:choose>
                        </xsl:attribute>
                        <a>
                            <xsl:attribute name="href">
                                /<xsl:value-of select="@url"/>
                            </xsl:attribute>
                            <xsl:attribute name="class">
                                <xsl:choose>
                                    <xsl:when test="$SelfOrChildSelected">MSC_PrimaryNavLink-On</xsl:when>
                                    <xsl:otherwise>MSC_PrimaryNavLink</xsl:otherwise>
                                </xsl:choose>
                            </xsl:attribute>
                            <xsl:value-of select="@name"/>
                        </a>
                        <xsl:if test="$SelfOrChildSelected">
                            <xsl:if test="count(child::*) != '0'">
                              <table cellpadding="0" cellspacing="0" class="MSC_SecondaryNavFrame" >
                                    <xsl:for-each select="NavNode">
                                        <xsl:if test="position() &gt; 1 ">
                                            <tr>
                                                <td>
                                                    <xsl:attribute name="class">MSC_SecondaryNavTopSpace</xsl:attribute>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <xsl:attribute name="class">MSC_SecondaryNavBottomSpace</xsl:attribute>
                                                </td>
                                            </tr>
                                        </xsl:if>
                                        <tr>
                                            <td>
                                                <xsl:attribute name="class">
                                                    <xsl:choose>
                                                        <xsl:when test="@selected='true'">MSC_SecondaryNavLinkFrame-On</xsl:when>
                                                        <xsl:otherwise>MSC_SecondaryNavLinkFrame</xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:attribute>
                                                <a>
                                                    <xsl:attribute name="href">
                                                        /<xsl:value-of select="@url"/>
                                                    </xsl:attribute>
                                                    <xsl:attribute name="class">
                                                        <xsl:choose>
                                                            <xsl:when test="@selected='true'">MSC_SecondaryNavLink-On</xsl:when>
                                                            <xsl:otherwise>MSC_SecondaryNavLink</xsl:otherwise>
                                                        </xsl:choose>
                                                    </xsl:attribute>
                                                    <xsl:value-of select="@name"/>
                                                </a>
                                            </td>
                                        </tr>
                                    </xsl:for-each>
                                </table>
                            </xsl:if>
                        </xsl:if>
                    </td>
                </tr>
                <tr>
                    <td class="MSC_PrimaryNavTopSpace">
                    </td>
                </tr>
                <tr>
                    <td class="MSC_PrimaryNavBottomSpace">
                    </td>
                </tr>
            </xsl:for-each>
        </table>
    </xsl:template>
</xsl:stylesheet>
