<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ou="http://omniupdate.com/XSL/Variables"
xmlns:ouc="http://omniupdate.com/XSL/Variables"
exclude-result-prefixes="xsl xs ou ouc">
  
  <!--  Importing files to acquire their functionality of templates and parameters. All imported templates and parameters have lower priority. 
  This makes it possible to define templates or parameters with the same name/match conditions and redefine their functionality. -->
  <xsl:import href="common.xsl" />
  <!-- This is the primary page-content template -->
  <xsl:template name="page-content">
	  <xsl:choose>
	  	<xsl:when test="$pageType='splash'">
	    	<xsl:apply-templates select="ouc:div[@label='maincontent']" />
		</xsl:when>
		<xsl:otherwise>

	  <div class="container">
		  
	    <div class="row">
			<xsl:call-template name="breadcrumbs"/>
			<xsl:if test="$sidenav='true'">
				<div id="sidebar">
					<xsl:call-template name="side-navigation" />
					<xsl:choose>
						<xsl:when test="$showSideContent='true'">
	    					<xsl:apply-templates select="ouc:div[@label='sidecontent']" />
						</xsl:when>
						<xsl:otherwise>
							<xsl:copy-of select="ou:includeFile('/_resources/includes/global/schoolsnav.inc')"/>
						</xsl:otherwise>
					</xsl:choose>
				</div>			
			</xsl:if>
        <div id="main-content">
			<xsl:if test="$sidenav='false'">
				<xsl:attribute name="class">fullwidth</xsl:attribute>
			</xsl:if>

		  <!-- ************************************** -->
		  <!-- Begin OU Campus Interior Page Editable Region -->
			<xsl:apply-templates select="ouc:div[@label='maincontent']" />
		  <!-- End OU Campus Interior Page Editable Region -->
		  <!-- ************************************** -->
		</div>
	  </div>
	  </div>		  
		</xsl:otherwise>
	  </xsl:choose>

 </xsl:template>
	
	<xsl:template name="side-navigation">
		<xsl:param name="column">side</xsl:param>
		<xsl:variable name="base-dir-count" select="count(tokenize($ou:dirname,'/'))" />
		<xsl:variable name="dir-count" select="if(contains($ou:filename,'index.')) then $base-dir-count else 1" />
		<xsl:variable name="sidenav-loc" select="if($dir-count lt 3) then $ou:dirname else ou:findPrevDir($ou:dirname)" />
		<xsl:variable name="sidenav-title-loc" select="if(contains($ou:filename,'index.') and $base-dir-count > 2) then ou:findPrevDir($ou:dirname) else $ou:dirname" />
		<h3 class="navtitle"><a href="{$sidenav-title-loc}"><xsl:value-of select="ou:getDirectoryTitle(concat($sidenav-title-loc,'/'),'index.pcf')" /></a></h3>
		<ul class="side-nav">
			<xsl:copy-of select="ou:includeFile($sidenav-loc,'_sidenav.inc',if($dir-count gt 2) then concat('sidenav-',$column) else (concat('sidenav-',$column),'Everyone','Side Navigation'))" />
		</ul>
		<xsl:if test="$dir-count gt 2">
			<ul class="side-subnav">
				<xsl:copy-of select="ou:includeFile($ou:dirname,'_sidenav.inc',(concat('subnav-',$column),'Everyone','Side Navigation'))" />
			</ul>
		</xsl:if>	
	</xsl:template>
</xsl:stylesheet>

