<?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="prc_th2_navigation.xsl"/>
	<xsl:include href="prc_th2_pag_general.xsl"/>
	<xsl:include href="prc_th2_com_shell.xsl"/>
	<xsl:include href="prc_th2_pag_home.xsl"/>
	<xsl:include href="prc_th2_pag_sitemap.xsl"/>
	<xsl:include href="prc_th2_pag_search.xsl"/>
	<xsl:include href="tracker.xsl" />

<!-- START VARIABLES -->
	
	<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="currentpagename" select="document(concat('pag_xml.php?id=', $currentpage))/page/name"/>
	
	<xsl:variable name="contentpage" select="$currentpage"/>
	
	<xsl:variable name="homepage" select="document(concat('sit_xml.php?id=', $site))/site/prc/navigation/utilitynav/page[1]/@id"/>
	
	<xsl:variable name="site" select="/page/@siteid"/>
	
	<xsl:variable name="parentsite" select="$site"/>
	
	<xsl:variable name="level">
		<xsl:for-each select="document(concat('sit_xml.php?id=', $site))/descendant::page[@id=$currentpage]">
			<xsl:value-of select="count(ancestor-or-self::page)"/>
		</xsl:for-each>
	</xsl:variable>
	
	<xsl:variable name="navtype"> 
		<xsl:for-each select="document(concat('sit_xml.php?id=', $site))/descendant::page[@id=$currentpage]">
			<xsl:value-of select="name(ancestor::*[number($level)])"/>
		</xsl:for-each>
	</xsl:variable>
	
	<xsl:variable name="section">
		<xsl:for-each select="document(concat('sit_xml.php?id=', $site))/descendant::page[@id=$currentpage]">
			<xsl:if test="name(ancestor::*[number($level)]) = 'globalnav'">global</xsl:if>
			<xsl:if test="name(ancestor::*[number($level)]) = 'quicknav'">quick</xsl:if>
			<xsl:if test="name(ancestor::*[number($level)]) = 'utilitynav'">utility</xsl:if>
			<xsl:if test="name(ancestor::*[number($level)]) = 'coursenav'">course</xsl:if>
		</xsl:for-each>
	</xsl:variable>	
	
	<xsl:variable name="primarypage">
		<xsl:for-each select="document(concat('sit_xml.php?id=', $site))/descendant::page[@id=$currentpage]">
			<xsl:choose>
			<xsl:when test="$level = 3">
			<xsl:value-of select="ancestor::page[number(2)]/@id"/>
			</xsl:when>
			<xsl:when test="$level = 2">
			<xsl:value-of select="ancestor::page[number(1)]/@id"/>
			</xsl:when>
			<xsl:otherwise>
			<xsl:value-of select="$currentpage"/>
			</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:variable>
	
	<xsl:variable name="pos">
		<xsl:for-each select="document(concat('sit_xml.php?id=', $site))/descendant::page[@id=$primarypage]">
			<xsl:number />
		</xsl:for-each>
	</xsl:variable>
	
	<xsl:variable name="primaryname">
		<xsl:value-of select="document(concat('pag_xml.php?id=', $primarypage))/page/name"/>
	</xsl:variable>
	
	<xsl:variable name="secondarypage">
		<xsl:for-each select="document(concat('sit_xml.php?id=', $site))/descendant::page[@id=$currentpage]">
			<xsl:choose>
			<xsl:when test="$level = 3">
			<xsl:value-of select="ancestor::page[number(1)]/@id"/>
			</xsl:when>
			<xsl:otherwise>
			<xsl:value-of select="$currentpage"/>
			</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:variable>
	
	<xsl:variable name="secondaryname">
		<xsl:value-of select="document(concat('pag_xml.php?id=', $secondarypage))/page/name"/>
	</xsl:variable>



<!-- 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>
       	       	       	        <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>				
				<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"/><link rel="stylesheet" type="text/css" href="prc_th2_css/screen.css" media="screen" /><link rel="stylesheet" type="text/css" href="prc_th2_css/oldstyles.css" media="screen" /><link rel="stylesheet" href="prc_th2_css/sIFR-screen.css" type="text/css" media="screen" /><link rel="stylesheet" href="prc_th2_css/sIFR-print.css" type="text/css" media="print" />
				
				
				
				
				
				<xsl:comment><![CDATA[[if IE]><link rel="stylesheet" type="text/css" media="screen" href="prc_th2_css/screen.ie.css" /><![endif]]]></xsl:comment>
				<xsl:comment><![CDATA[[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="prc_th2_css/screen.ie6.css" /><![endif]]]></xsl:comment>
				<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">prc_th2_js/css_include.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">prc_th2_js/sifr.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">prc_th2_js/sifr-addons.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:attribute name="class">
					<xsl:choose>
						<xsl:when test="$currentpage = $homepage"><xsl:text>homepage</xsl:text></xsl:when>
						<xsl:otherwise><xsl:text>sub_index</xsl:text></xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
				<div class="wrapper-outer">
					<div class="header">
						<xsl:if test="document(concat('sit_xml.php?id=', @siteid))/site/prc/logo/@filename != ''">
						<a href="page.php?id={document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/utilitynav/page[1]/@id}" title="{document(concat('sit_xml.php?id=', @siteid))/site/name}" class="left"><img src="{document(concat('sit_xml.php?id=', @siteid))/site/prc/logo/@filename}" alt="{document(concat('sit_xml.php?id=', @siteid))/site/prc/logo/@filename}" /></a>
						</xsl:if>
						<div class="right">
							<form method="post" action="search.php">
								<div>
									<label for="search">Search</label><xsl:text> </xsl:text>
									<input type="hidden" name="site" value="{@siteid}" />
									<input type="hidden" name="type" value="prc" />
									<input type="text" size="10" id="searchtxt" />
									<input type="submit" value="Search" class="submit" />
								</div>
							</form>
						</div>
					</div>
					<div class="content1-wrapper-outer">
						<div class="content1-wrapper" style="background-image: url({document(concat('sit_xml.php?id=', @siteid))/site/prc/image/@filename})">
							<xsl:element name="div"><xsl:attribute name="class">mask</xsl:attribute><xsl:text> </xsl:text>
								<xsl:choose>
									<xsl:when test="$currentpage = $homepage">
											<div class="content1">
												<div class="block">
													<h2><span><xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/name"/></span></h2>
													<p>
														<xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/description" disable-output-escaping="yes"/>													</p>
												</div>
												<div class="navigation">
													<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/sitenav"/>
													<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/globalnav"/>												</div>
											</div>
									</xsl:when>
									<xsl:otherwise>
										
										<div class="navigation">
											<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/sitenav"/>
											<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/globalnav" mode="sub_index" />
											<xsl:if test="$currentpage!=$homepage"><xsl:element name="div"><xsl:attribute name="class">corner</xsl:attribute>&#160;</xsl:element></xsl:if>
											<div style="clear: both; font-size: 0; line-height: 0; visibility: hidden;"><xsl:text> </xsl:text></div>
										</div>
										
										<div class="content1">
											<div class="block leading-block">
												<!--xsl:element name="a">
													<xsl:attribute name="class">breadcrumb</xsl:attribute>
													<xsl:attribute name="href">page.php?id=<xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/utilitynav/page[1]/@id" /></xsl:attribute>
													<xsl:attribute name="title"><xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/name" /></xsl:attribute>
													home
												</xsl:element-->
												<xsl:element name="h2">
													<xsl:element name="span">
														<xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/name" />
													</xsl:element>
												</xsl:element>
												<xsl:element name="h3">
													<xsl:element name="span">
														<xsl:attribute name="class">sifr</xsl:attribute>
														<xsl:value-of select="document(concat('pag_xml.php?id=', $currentpage))/page/name" />
													</xsl:element>
												</xsl:element>
											</div>
											<xsl:apply-templates select="globalnavpage"/>	
											<xsl:apply-templates select="sitenavpage"/>	
											<xsl:apply-templates select="utility"/>	
											<xsl:apply-templates select="quicknavpage"/>	
											<xsl:apply-templates select="home"/>	
											<xsl:apply-templates select="sitemap"/>	
											<xsl:apply-templates select="search"/>	
&#160;										</div>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:element>
						</div>
					</div>
					<xsl:if test="$currentpage = $homepage">
						<div class="content2-wrapper-outer">
							<div class="content2-wrapper">
								<div class="content2">
									<xsl:apply-templates select="home"/>	
									<xsl:apply-templates select="sitemap"/>	
									<xsl:apply-templates select="search"/>
									<xsl:apply-templates select="utility"/>	
								</div>
							</div>
						</div>
					</xsl:if>
					<div class="footer">
						<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/utilitynav"/>
						<p class="disclaimer"> Copyright &#169; JHU CTE Online Learning Management System 2005 </p>
						
						
						
					</div>
				</div>	
				<!--div id="wrapper">
					<ul id="globalnav" class="clearfix">
						<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/globalnav"/>
					</ul>	
					<xsl:choose>
					<xsl:when test="$currentpage = $homepage">	
					<div id="header" style="background-image: url({document(concat('sit_xml.php?id=', @siteid))/site/prc/image/@filename})">
						<div id="logo-holder">
							<xsl:element name="img">
							<xsl:choose>
							<xsl:when test="document(concat('sit_xml.php?id=', @siteid))/site/prc/logo/@filename">
							<xsl:attribute name="src"><xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/prc/logo/@filename"/></xsl:attribute>
							</xsl:when>
							<xsl:otherwise>
							<xsl:attribute name="src">images/default_prc_logo.gif</xsl:attribute>
							</xsl:otherwise>
							</xsl:choose>
							<xsl:attribute name="id"><xsl:text>prc-logo</xsl:text></xsl:attribute>
							<xsl:attribute name="alt"><xsl:text>Public Resource Center Logo</xsl:text></xsl:attribute>
							</xsl:element>
						</div>
						<h1><xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/name"/></h1>		
						<div id="home-quicknav">
						<form>
							<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/quicknav"/>	
						</form>
						<form action="search.php" method="post">
							<fieldset>
							<h3><label for="search">Search by keyword</label></h3>
							<input type="hidden" name="site" value="{@siteid}" />
							<input type="hidden" name="type" value="prc" />
							<input type="text" name="searchtxt" id="search"/><button type="submit" title="Search"><img src="images/icon_search.gif" alt="Search"/></button>
							</fieldset>
						</form>			
						</div>			
						<p><xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/description" disable-output-escaping="yes"/></p>
						<ul id="topicnav" class="clearfix">
							<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/sitenav"/>
						</ul>
					</div>		
					</xsl:when>
					<xsl:otherwise>	
					<div id="header" style="background-image: url({document(concat('sit_xml.php?id=', @siteid))/site/prc/image/@filename})">
						<div id="logo-holder">
							<xsl:element name="img">
							<xsl:choose>
							<xsl:when test="document(concat('sit_xml.php?id=', @siteid))/site/prc/logo/@filename">
							<xsl:attribute name="src"><xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/prc/logo/@filename"/></xsl:attribute>
							</xsl:when>
							<xsl:otherwise>
							<xsl:attribute name="src">images/default_prc_logo.gif</xsl:attribute>
							</xsl:otherwise>
							</xsl:choose>
							<xsl:attribute name="id"><xsl:text>prc-logo</xsl:text></xsl:attribute>
							<xsl:attribute name="alt"><xsl:text>Public Resource Center Logo</xsl:text></xsl:attribute>
							</xsl:element>
						</div>
						<h1><xsl:value-of select="document(concat('sit_xml.php?id=', @siteid))/site/name"/></h1>
					</div>	
					<xsl:element name="div">
						<xsl:attribute name="id">subnav</xsl:attribute>
						<xsl:attribute name="class"><xsl:if test="$navtype = 'sitenav'">t<xsl:value-of select="$pos"/></xsl:if><xsl:text> clearfix</xsl:text></xsl:attribute>
						<h2 class=""><a href="page.php?id={$homepage}">&lt; Home</a><br/><br/>
						<xsl:value-of select="$primaryname"/></h2>
						<ul class="secondary">
							<xsl:call-template name="sidenav"/>
						</ul>
						<div id="sub-quicknav">
						<form action="search.php" method="post">
							<input type="hidden" name="site" value="{@siteid}" />
							<input type="hidden" name="type" value="prc" />
							<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/quicknav"/>	
							<fieldset>
								<h3><label for="search">Search by keyword</label></h3>
								<input type="text" name="searchtxt" id="search"/><button type="submit" title="Search"><img src="images/icon_search.gif" alt="Search"/></button>
							</fieldset>
						</form>		
						</div>
					</xsl:element>
					</xsl:otherwise>
					</xsl:choose>
					<div id="shadow">
					</div>	
					<div id="content">
					<xsl:apply-templates select="globalnavpage"/>	
					<xsl:apply-templates select="sitenavpage"/>	
					<xsl:apply-templates select="utility"/>	
					<xsl:apply-templates select="quicknavpage"/>	
					<xsl:apply-templates select="home"/>	
					<xsl:apply-templates select="sitemap"/>	
					<xsl:apply-templates select="search"/>	
					&#160;
					</div>
					<div id="footer" class="clearfix">
						<xsl:apply-templates select="document(concat('sit_xml.php?id=', @siteid))/site/prc/navigation/utilitynav"/>
					</div><br/>
					<span id="copyright">Copyright &#169; JHU CTE Online Learning Management System 2005</span>				
				</div-->	
				<xsl:choose>
					<xsl:when test="$currentpage = $homepage">
						<script type="text/javascript">
							//<![CDATA[
								if(typeof sIFR == "function"){
									sIFR.replaceElement(named({sSelector:".sIFR-hasFlash body.homepage div.content1 h2 span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sColor:"#000000", sLinkColor:"#000000", sBgColor:"#FFFFFF", sWmode:"transparent", sHoverColor:"#CCCCCC"}));
									//sIFR.replaceElement(named({sSelector:".sIFR-hasFlash body.homepage div.wrapper-outer div.content1-wrapper div.navigation ul.feature li.color1 span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sLinkColor:"#9e77d2", sBgColor:"#FFFFFF", sWmode:"transparent", sCase:"upper", sFlashVars:"offsetTop=4"}));
									//sIFR.replaceElement(named({sSelector:".sIFR-hasFlash body.homepage div.wrapper-outer div.content1-wrapper div.navigation ul.feature li.color2 span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sLinkColor:"#c63d1e", sBgColor:"#FFFFFF", sWmode:"transparent", sCase:"upper", sFlashVars:"offsetTop=4"}));
									//sIFR.replaceElement(named({sSelector:".sIFR-hasFlash body.homepage div.wrapper-outer div.content1-wrapper div.navigation ul.feature li.color3 span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sLinkColor:"#e2a021", sBgColor:"#FFFFFF", sWmode:"transparent", sCase:"upper", sFlashVars:"offsetTop=4"}));
									//sIFR.replaceElement(named({sSelector:".sIFR-hasFlash body.homepage div.wrapper-outer div.content1-wrapper div.navigation ul.feature li.color4 span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sLinkColor:"#428643", sBgColor:"#FFFFFF", sWmode:"transparent", sCase:"upper", sFlashVars:"offsetTop=4"}));
									//sIFR.replaceElement(named({sSelector:".sIFR-hasFlash body.homepage div.wrapper-outer div.content1-wrapper-outer div.content1-wrapper div.content1 div.navigation div.global ul li span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sColor:"#353535", sLinkColor:"#353535", sHoverColor:"#000000", sBgColor:"#FFFFFF", sWmode:"transparent"}));
								};
							//]]>
						</script>
					</xsl:when>
					<xsl:otherwise>
						<script type="text/javascript">
							//<![CDATA[
								if(typeof sIFR == "function"){
									sIFR.replaceElement(named({sSelector:".sIFR-hasFlash div.wrapper-outer div.content1-wrapper-outer div.content1-wrapper div.content1 div.block h2 span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sColor:"#555555", sLinkColor:"#555555", sBgColor:"#FFFFFF", sWmode:"transparent", sHoverColor:"#555555", sFlashVars:"offsetTop=1"}));
									//sIFR.replaceElement(named({sSelector:".sIFR-hasFlash div.wrapper-outer div.content1-wrapper div.navigation ul.feature li.color1 span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sLinkColor:"#9e77d2", sColor:"#9e77d2", sBgColor:"#FFFFFF", sWmode:"transparent", sCase:"upper", sFlashVars:"offsetTop=3"}));
									//sIFR.replaceElement(named({sSelector:".sIFR-hasFlash div.wrapper-outer div.content1-wrapper div.navigation ul.feature li.color2 span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sLinkColor:"#c63d1e", sColor:"#c63d1e", sBgColor:"#FFFFFF", sWmode:"transparent", sCase:"upper", sFlashVars:"offsetTop=3"}));
									//sIFR.replaceElement(named({sSelector:".sIFR-hasFlash div.wrapper-outer div.content1-wrapper div.navigation ul.feature li.color3 span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sLinkColor:"#e2a021", sColor:"#e2a021", sBgColor:"#FFFFFF", sWmode:"transparent", sCase:"upper", sFlashVars:"offsetTop=3"}));
									//sIFR.replaceElement(named({sSelector:".sIFR-hasFlash div.wrapper-outer div.content1-wrapper div.navigation ul.feature li.color4 span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sLinkColor:"#428643", sColor:"#428643", sBgColor:"#FFFFFF", sWmode:"transparent", sCase:"upper", sFlashVars:"offsetTop=3"}));
									//sIFR.replaceElement(named({sSelector:".sIFR-hasFlash .global ul li span", sFlashSrc:"prc_th2_fonts/30640bc.swf", sColor:"#353535", sLinkColor:"#353535", sHoverColor:"#000000", sBgColor:"#FFFFFF", sWmode:"transparent"}));
									sIFR.replaceElement(named({sSelector:".sIFR-hasFlash body.sub_index div.content1 h3 span.sifr", sFlashSrc:"prc_th2_fonts/30640bc.swf", sColor:"#000000", sLinkColor:"#000000", sBgColor:"#FFFFFF", sWmode:"transparent", sHoverColor:"#CCCCCC"}));
								};
							//]]>
						</script>
					</xsl:otherwise>
				</xsl:choose>
  			<xsl:call-template name="tracker"/>	
			</xsl:element>
		</html>
	</xsl:template>
	
</xsl:stylesheet>

