<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output method="xml" indent="no"/>
	
<!-- HOMENAV -->

	<xsl:template name="homenav">
		<ul id="homenav" xmlns="http://www.w3.org/1999/xhtml">
		<xsl:for-each select="document(concat('sit_xml.php?id=', /page/@siteid))/site/course/navigation/quicknav/page">
			<li><a href="page.php?id={document(concat('pag_xml.php?id=', @id))/page/@id}" rel="subsection"><img src="images/mn_ses_ar_off.gif" alt="Open"/><xsl:value-of select="document(concat('pag_xml.php?id=', @id))/page/name"/></a></li>
		</xsl:for-each>
		</ul>
		
	</xsl:template>
	
<!-- QUICKNAV -->
	
	<xsl:template match="quicknav">	
		<li class="mainnav" xmlns="http://www.w3.org/1999/xhtml"><a href="javascript:swap_menu('menu1')" rel="section"><img src="images/mainnav_i.gif" alt="-"/><xsl:value-of select="name"/></a>
			<xsl:element name="ul"><xsl:attribute name="class">maininfo</xsl:attribute><xsl:attribute name="id">menu1</xsl:attribute><xsl:choose><xsl:when test="descendant::page[@id=$currentpage]"><xsl:attribute name="style">display: block;</xsl:attribute></xsl:when><xsl:otherwise><xsl:attribute name="style">display: none;</xsl:attribute></xsl:otherwise></xsl:choose>	
			<xsl:choose>
			<xsl:when test="page">		
			<xsl:for-each select="page">
			<xsl:element name="li">
			<xsl:attribute name="class">info <xsl:if test="position() = 1">top</xsl:if><xsl:if test="@id = $currentpage">on</xsl:if></xsl:attribute>
			<a href="page.php?id={document(concat('pag_xml.php?id=', @id))/page/@id}" rel="subsection"><xsl:value-of select="document(concat('pag_xml.php?id=', @id))/page/name"/></a>
			</xsl:element>
			</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>&#160;</xsl:otherwise>
			</xsl:choose>	
			</xsl:element>
			<xsl:if test="descendant::page[@id=$currentpage]">
			<script type="text/JavaScript">
				swap_menu('menu1')
			</script>
			</xsl:if></li>
	</xsl:template>
	
<!-- GLOBALNAV -->
	
	<xsl:template match="globalnav">
		<li class="mainnav" xmlns="http://www.w3.org/1999/xhtml"><a href="javascript:swap_menu('menu2')" rel="section"><img src="images/mainnav_c.gif" alt="-"/><xsl:value-of select="name"/></a>
			<xsl:element name="ul"><xsl:attribute name="class">mainses</xsl:attribute><xsl:attribute name="id">menu2</xsl:attribute><xsl:choose><xsl:when test="descendant::page[@id=$currentpage]"><xsl:attribute name="style">display: block;</xsl:attribute></xsl:when><xsl:otherwise><xsl:attribute name="style">display: none;</xsl:attribute></xsl:otherwise></xsl:choose>
				<xsl:choose>
				<xsl:when test="page">
				<xsl:for-each select="page">
				<xsl:element name="li"><xsl:attribute name="class">ses <xsl:if test="position() = 1">top</xsl:if><xsl:if test="@id = $session">on</xsl:if></xsl:attribute>		
				<a href="javascript:swap_ses('ses{position()}')" rel="subsection" style="float: left"><img src="images/mn_ses_ar_off.gif" alt="Open"/></a><a href="page.php?id={document(concat('pag_xml.php?id=', @id))/page/@id}" class="sessionlink"><xsl:value-of select="document(concat('pag_xml.php?id=', @id))/page/name"/></a>
				<xsl:element name="ul"><xsl:attribute name="class">mainact</xsl:attribute><xsl:attribute name="id">ses<xsl:value-of select="position()"/></xsl:attribute><xsl:choose><xsl:when test="descendant::page[@id=$currentpage]"><xsl:attribute name="style">display: block;</xsl:attribute></xsl:when><xsl:otherwise><xsl:attribute name="style">display: none;</xsl:attribute></xsl:otherwise></xsl:choose>
					<xsl:choose>
					<xsl:when test="page">
					<xsl:for-each select="page">
					<xsl:element name="li">
					<xsl:attribute name="class"><xsl:text>act </xsl:text><xsl:if test="@id = $activity">on </xsl:if><xsl:if test="document(concat('pag_xml.php?id=', @id))/page/activity/required = '1'">req</xsl:if></xsl:attribute>
					<xsl:element name="a">
						<xsl:attribute name="href"><xsl:choose><xsl:when test="page/@id &gt; 0">page.php?id=<xsl:value-of select="page/@id"/></xsl:when><xsl:otherwise>nocontent.html</xsl:otherwise></xsl:choose></xsl:attribute>
						<xsl:value-of select="document(concat('pag_xml.php?id=', @id))/page/name"/>
					</xsl:element>
					</xsl:element>
					</xsl:for-each>
					</xsl:when>
					<xsl:otherwise>&#160;</xsl:otherwise>
					</xsl:choose>					
				</xsl:element>
				<xsl:if test="descendant-or-self::page[@id=$currentpage]">
				<script type="text/JavaScript">
					swap_ses('ses<xsl:value-of select="position()"/>')
				</script>
				</xsl:if></xsl:element>
			</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>&#160;</xsl:otherwise>
			</xsl:choose>	
		</xsl:element>
		<xsl:if test="descendant::page[@id=$currentpage]">
		<script type="text/JavaScript">
			swap_menu('menu2')
		</script>
		</xsl:if></li>
	</xsl:template>
	
<!-- UTILITYNAV -->
	
	<xsl:template match="utilitynav">
		<xsl:for-each select="page">	
			<li xmlns="http://www.w3.org/1999/xhtml"><a href="page.php?id={@id}" rel="home"><img src="images/util_{name(document(concat('pag_xml.php?id=', @id))/page/*[3])}_icon.gif" alt="-"/><xsl:value-of select="document(concat('pag_xml.php?id=', @id ))/page/name"/></a></li>
		</xsl:for-each>
		<li><a href="#" onclick="window.print(); return false;" rel="print"><img src="images/util_print_icon.gif" alt="-"/>Print</a></li>
	</xsl:template>
	
</xsl:stylesheet>

