<?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"/>
	
	<xsl:include href="course_th3_navigation.xsl"/>
	<xsl:include href="course_th3_pag_home.xsl"/>
	<xsl:include href="course_th3_pag_quicknav.xsl"/>
	<xsl:include href="course_th3_pag_utility.xsl"/>
	<xsl:include href="course_th3_pag_sitemap.xsl"/>
	<xsl:include href="course_th3_pag_session.xsl"/>
	<xsl:include href="course_th3_pag_search.xsl"/>
	<xsl:include href="course_th3_pag_activitypage.xsl"/>
	<xsl:include href="course_th3_com_shell.xsl"/>
	<xsl:include href="tracker.xsl" />

<!-- START VARIABLES -->


	<xsl:variable name="condensed"><xsl:value-of select="/page/@condensed"/></xsl:variable>
	
	<xsl:variable name="import"><xsl:value-of select="/page/@import"/></xsl:variable>

	<xsl:variable name="state">site</xsl:variable>
	
	<xsl:variable name="currentpage" select="/page/@id"/>
	
	<xsl:variable name="contentpage" select="$currentpage"/>
	
	<xsl:variable name="homepage" select="document(concat('sit_xml.php?id=', $site))/site/course/navigation/utilitynav/page[1]/@id"/>
	
	<xsl:variable name="site" select="/page/@siteid"/>
	
	<xsl:variable name="parentname"><xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$currentpage]"><xsl:value-of select="name(parent::*)"/></xsl:for-each></xsl:variable>
	
	<xsl:variable name="currentpagetype">
		<xsl:if test="$parentname = 'globalnav'">session</xsl:if>
		<xsl:if test="$parentname = 'page'">activitypage</xsl:if>
		<xsl:if test="$parentname = 'quicknav'">quicknav</xsl:if>
		<xsl:if test="$parentname = 'utilitynav'">utility</xsl:if>
	</xsl:variable>
	
	<xsl:variable name="sessionrtf">
		<xsl:choose>
		<xsl:when test="$currentpagetype = 'session'">
			<xsl:value-of select="$currentpage"/>
		</xsl:when>
		<xsl:when test="$currentpagetype = 'activitypage'">
			<xsl:for-each select="document(concat('sit_xml.php?id=', $site))/descendant::page[@id=$currentpage]">
				<xsl:value-of select="../../@id"/>
			</xsl:for-each>				
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="number(0)"/>
		</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="session" select="$sessionrtf"/>
	
	<xsl:variable name="sesposrtf">
		<xsl:choose>
			<xsl:when test="$currentpagetype = 'session' or $currentpagetype = 'activitypage'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$session]">
					<xsl:value-of select="count(preceding-sibling::page) + 1"/>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="sespos" select="$sesposrtf"/>
	
	<xsl:variable name="activityrtf">
		<xsl:choose>
			<xsl:when test="$currentpagetype = 'activitypage'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$currentpage]">
					<xsl:value-of select="../@id"/>
				</xsl:for-each>				
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="activity" select="$activityrtf"/>
	
	<xsl:variable name="actposrtf">
		<xsl:choose>
			<xsl:when test="$currentpagetype = 'activitypage'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$activity]">
					<xsl:value-of select="count(preceding-sibling::page) + 1"/>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="actpos" select="$actposrtf"/>
	
	<xsl:variable name="activitypagertf">
		<xsl:choose>
			<xsl:when test="$currentpagetype = 'activitypage'">
				<xsl:value-of select="$currentpage"/>			
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="activitypage" select="$activitypagertf"/>
	
	<xsl:variable name="pagposrtf">
		<xsl:choose>
			<xsl:when test="$currentpagetype = 'activitypage'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$currentpage]">
					<xsl:value-of select="count(preceding-sibling::*) + 1"/>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="pagpos" select="$pagposrtf"/>
	
	<xsl:variable name="presesrtf">
		<xsl:choose>
			<xsl:when test="$sespos &gt; '1'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$session]">
					<xsl:value-of select="preceding-sibling::page[1]/@id"/>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="preses" select="$presesrtf"/>
	
	<xsl:variable name="folsesrtf">
		<xsl:choose>
			<xsl:when test="$currentpagetype = 'activitypage' or $currentpagetype = 'session'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$session]">
					<xsl:choose>
						<xsl:when test="following-sibling::page[1]/@id &gt; 0">
							<xsl:value-of select="following-sibling::page[1]/@id"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="number(0)"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="folses" select="$folsesrtf"/>
	
	<xsl:variable name="preactrtf">
		<xsl:choose>
			<xsl:when test="$actpos &gt; '0'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$activity]">
					<xsl:value-of select="preceding-sibling::page[1]/@id"/>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="preact" select="$preactrtf"/>
	
	<xsl:variable name="folactrtf">
		<xsl:choose>
			<xsl:when test="$currentpagetype = 'activitypage' or $currentpagetype = 'session'">
				<xsl:choose>
					<xsl:when test="$currentpagetype = 'activitypage'">
						<xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$activity]">
							<xsl:choose>
								<xsl:when test="following-sibling::page[1]/@id &gt; 0">
									<xsl:value-of select="following-sibling::page[1]/@id"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="number(0)"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:for-each>
					</xsl:when>
					<xsl:otherwise>
						<xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$session]">
							<xsl:choose>
								<xsl:when test="child::page[1]/@id &gt; 0">
									<xsl:value-of select="child::page[1]/@id"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="number(0)"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:for-each>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="folact" select="$folactrtf"/>
	
	<xsl:variable name="preactpagertf">
		<xsl:choose>
			<xsl:when test="$preact &gt; '0'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site ))/descendant::page[@id=$preact]">
					<xsl:choose>
						<xsl:when test="child::page[1]/@id &gt; '0'">
							<xsl:value-of select="child::page[1]/@id"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="number(0)"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>		
	
	<xsl:variable name="preactpage" select="$preactpagertf"/>
	
	<xsl:variable name="folactpagertf">
		<xsl:choose>
			<xsl:when test="$folact &gt; '0'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site))/descendant::page[@id=$folact]">
					<xsl:choose>
						<xsl:when test="child::page[1]/@id &gt; '0'">
							<xsl:value-of select="child::page[1]/@id"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="number(0)"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>		
	
	<xsl:variable name="folactpage" select="$folactpagertf"/>	
	
	<xsl:variable name="prepagrtf">
		<xsl:choose>
			<xsl:when test="$pagpos &gt; '1'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site))/descendant::page[@id=$currentpage]">
					<xsl:value-of select="preceding-sibling::page[1]/@id"/>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="prepag" select="$prepagrtf"/>	
	
	<xsl:variable name="folpagrtf">
		<xsl:choose>
			<xsl:when test="$currentpagetype = 'activitypage'">
				<xsl:for-each select="document(concat('sit_xml.php?id=', $site))/descendant::page[@id=$currentpage]">
					<xsl:choose>
						<xsl:when test="following-sibling::page[1]/@id &gt; 0">
							<xsl:value-of select="following-sibling::page[1]/@id"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="number(0)"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number(0)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	
	<xsl:variable name="folpag" select="$folpagrtf"/>	

<!-- END VARIABLES -->	

	<xsl:template match="page">
		<xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</xsl:text>
		<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
		
			<head>
				<title><xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/title"/></title>
				<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
       	       	       	        <xsl:element name="base"><xsl:attribute	name="href"><xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/basehref"/></xsl:attribute></xsl:element>
				<link href="course_th3_css/universal.css" rel="stylesheet" media="screen" type="text/css"/>
				<link href="course_th3_css/universal_contentstyle.css" rel="stylesheet" media="screen" type="text/css"/>
				<link href="course_th3_css/{document(concat('sit_xml.php?id=', @siteid))/site/course/@theme}.css" rel="stylesheet" media="screen" type="text/css"/>
				<link href="course_th3_css/universal.css" rel="stylesheet" media="print" type="text/css"/>
				<xsl:if test="$import = 1 or $condensed = 1">
				<link href="course_th3_css/embed.css" rel="stylesheet" media="screen" type="text/css"/>
				</xsl:if>
				<link href="course_th3_css/universal_contentstyle.css" rel="stylesheet" media="print" type="text/css"/>
				<link href="course_th3_css/print.css" rel="stylesheet" media="print" type="text/css"/>				
				<xsl:comment><![CDATA[[if IE]><link rel="stylesheet" type="text/css" media="screen" href="prc_css/style_ie.css" /><![endif]]]></xsl:comment>
				<xsl:element name="script"><xsl:attribute name="type">text/JavaScript</xsl:attribute><xsl:attribute name="src">js/dhtml.js</xsl:attribute><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></xsl:element>
				<xsl:element name="script"><xsl:attribute name="type">text/JavaScript</xsl:attribute><xsl:attribute name="src">js/mouse_over.js</xsl:attribute><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></xsl:element>
				<xsl:element name="script"><xsl:attribute name="type">text/JavaScript</xsl:attribute><xsl:attribute name="src">js/mm.js</xsl:attribute><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></xsl:element>
			</head>
			<xsl:element name="body">
			<xsl:if test="$homepage = $currentpage">
			<xsl:attribute name="id">home</xsl:attribute>
			</xsl:if>
				<div id="wrapper" class="clearfix">	
					<div id="ltcol">		
						<div id="logo" class="clearfix" style="padding-bottom: 0px !important; padding-bottom: 5px; ">	
							<xsl:choose>
							<xsl:when test="document(concat('sit_xml.php?id=', @siteid))/site/course/logo/@filename">
							<img src="{document(concat('sit_xml.php?id=', @siteid))/site/course/logo/@filename}" alt="Course Logo" id="course-logo"/>	
							</xsl:when>	
							<xsl:otherwise>
							<img src="images/default_cte_logo.gif" alt="Course Logo" id="course-logo"/>
							</xsl:otherwise>
							</xsl:choose>	
						</div>	
						<ul id="mainnav">
							<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/course/navigation/quicknav"/>
							<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/course/navigation/globalnav"/>
							<li class="mainnav"><a href="javascript:swap_menu('menu3')" rel="section"><img src="images/mainnav_s.gif" alt="-"/>Search</a></li>		
						</ul>
						<div class="search" style="display: none;" id="menu3">
							<form action="search.php" method="post">
							<input type="hidden" name="site" value="{@siteid}" />
							<input type="hidden" name="type" value="course" />
							<p><label for="search">Search by keyword:</label><br/>
							<input type="text" size="12" name="searchtxt" id="search"/> <input type="submit" value="GO"/></p>
							</form>
						</div>	
					</div>		
					<div id="rtcol">	
							
						<xsl:apply-templates select="home"/>
						<xsl:apply-templates select="sitemap"/>
						<xsl:apply-templates select="quicknavpage"/>
						<xsl:apply-templates select="session"/>
						<xsl:apply-templates select="activitypage"/>	
						<xsl:apply-templates select="utility"/>		
						<xsl:apply-templates select="search"/>						
						
						<div id="footer">	
							<p>	
								<img src="images/cte_logo.gif" alt="CTE"/>
								<xsl:text disable-output-escaping="yes">&lt;br/&gt;
								Web site created by:&lt;br/&gt;
								The Center for Technology in Education (CTE)&lt;br/&gt;
								Johns Hopkins University
								</xsl:text>
							</p>			
						</div>	
						
					</div>
				</div>
  			<xsl:call-template name="tracker"/>	
			</xsl:element>
		</html>
	</xsl:template>
	
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2005. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios/><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->

