<?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"/>
	
<!-- SITEMAP -->
	
	<xsl:template match="sitemap">	
		<div id="header" xmlns="http://www.w3.org/1999/xhtml">
			<ul class="options-tp">
				<xsl:choose>
				<xsl:when test="document(concat('sit_xml.php?id=', /page/@siteid))/site/course/navigation/utilitynav/page">
				<xsl:apply-templates select="document(concat('sit_xml.php?id=', /page/@siteid))/site/course/navigation/utilitynav"/>
				</xsl:when>
				<xsl:otherwise>
				<li>&#160;</li>
				</xsl:otherwise>
				</xsl:choose>
			</ul>	
			<div id="titlebar">					
				<div>
					<h1><xsl:value-of select="document(concat('sit_xml.php?id=', /page/@siteid ))/site/name"/></h1>
					<h2><xsl:value-of select="/page/title"/></h2>
					<h3><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></h3>
				</div>			
			</div>			
		</div>	
		<div class="component" xmlns="http://www.w3.org/1999/xhtml">	
			<xsl:for-each select="document(concat('sit_xml.php?id=', /page/@siteid ))/site/course/navigation/utilitynav">	
			<h3>Utility Pages</h3>
				<table class="outline" style="width: 450px !important">
					<xsl:for-each select="page">
					<tr>
						<td> 						
						<xsl:element name="a">
							<xsl:attribute name="href">page.php?id=<xsl:value-of select="@id"/></xsl:attribute>
							<xsl:value-of select="document(concat('pag_xml.php?id=', @id))/page/name"/>
						</xsl:element></td>
					</tr>
					</xsl:for-each>
				</table>	
			</xsl:for-each>
		</div>		
		<div class="component" xmlns="http://www.w3.org/1999/xhtml">	
			<xsl:for-each select="document(concat('sit_xml.php?id=', /page/@siteid ))/site/course/navigation/quicknav">	
			<h3>Orientation Pages</h3>
				<table class="outline" style="width: 450px !important">
					<xsl:for-each select="page">
					<tr>
						<td> 						
						<xsl:element name="a">
							<xsl:attribute name="href">page.php?id=<xsl:value-of select="@id"/></xsl:attribute>
							<xsl:value-of select="document(concat('pag_xml.php?id=', @id))/page/name"/>
						</xsl:element></td>
					</tr>
					</xsl:for-each>
				</table>	
			</xsl:for-each>
		</div>		
		<div class="component" xmlns="http://www.w3.org/1999/xhtml">		
			<xsl:for-each select="document(concat('sit_xml.php?id=', /page/@siteid ))/site/course/navigation/globalnav/page">	
			<h3>Session: <a href="page.php?id={@id}"><xsl:value-of select="document(concat('pag_xml.php?id=', @id ))/page/name"/></a></h3>
			<p><xsl:value-of select="document(concat('pag_xml.php?id=', @id))/page/session/description"/></p>
				<xsl:if test="page/@id &gt; '0'">
					<xsl:param name="reqcount">
					<xsl:for-each select="page">
						<xsl:choose>
							<xsl:when test="document(concat('pag_xml.php?id=', @id ))/page/activity/required = 1">1</xsl:when>
							<xsl:otherwise>0</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
					</xsl:param>
					<xsl:param name="req">
						<xsl:choose>
							<xsl:when test="$reqcount &gt; 1">1</xsl:when>
							<xsl:otherwise>0</xsl:otherwise>
						</xsl:choose>
					</xsl:param>
					<xsl:param name="timecount">
					<xsl:for-each select="page">
						<xsl:choose>
							<xsl:when test="document(concat('pag_xml.php?id=', @id ))/page/activity/time != ''">1</xsl:when>
							<xsl:otherwise>0</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
					</xsl:param>
					<xsl:param name="time">
						<xsl:choose>
							<xsl:when test="$timecount &gt; 1">1</xsl:when>
							<xsl:otherwise>0</xsl:otherwise>
						</xsl:choose>
					</xsl:param>
				<table class="outline" style="width: 450px !important">
					<tr>
						<th>Activities</th>
						<xsl:if test="$req = 1">
						<th>Required</th>
						</xsl:if>
						<xsl:if test="$time = 1">
						<th>Time Required</th>
						</xsl:if>
						<th style="width:20px">Pages</th>
					</tr>
					<xsl:for-each select="page">
					<tr>
						<td>				
						<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></td>
						<xsl:if test="$req = 1">
						<td><xsl:choose><xsl:when test="document(concat('pag_xml.php?id=', @id ))/page/activity/required = 1">Yes</xsl:when><xsl:otherwise>No</xsl:otherwise></xsl:choose><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></td>
						</xsl:if>
						<xsl:if test="$time = 1">
						<td><xsl:value-of select="document(concat('pag_xml.php?id=', @id))/page/activity/time"/><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></td>
						</xsl:if>
						<td><xsl:value-of select="count(page)"/></td>
					</tr>
					</xsl:for-each>
				</table>	
				</xsl:if>
			</xsl:for-each>
		</div>			
	</xsl:template>
	
</xsl:stylesheet>
