<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<!--
COMMMON STYLESHEET for UAEX 2013 Implementation
Imported by all pagetype specific stylesheets, and imports utility stylesheets.
Defines html, xsl templates and functions used globally throughout the implementation
Defines outer html structure and common include content.

Contributors: Vinit Varghese, Caroline Spooner
Last Updated 10/08/2013
-->
<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:fn="http://omniupdate.com/XSL/Functions"
    xmlns:ouc="http://omniupdate.com/XSL/Variables"
    exclude-result-prefixes="ou xsl xs fn ouc">

<xsl:import href="template-matches.xsl"/> <!-- identity and misc/general matches -->
<xsl:import href="vars.xsl"/> <!-- oucampus parameters, directory variables, implementation variables -->
<xsl:import href="functions.xsl"/> 
<xsl:import href="breadcrumb.xsl"/> <!-- recursively displays web path -->
<xsl:import href="nested-nav.xsl"/> <!-- recursively copies _nav files -->
<xsl:import href="ouforms.xsl"/> <!-- LDP -->
<xsl:import href="ougalleries.xsl"/> <!-- LDP -->
<xsl:import href="special-templates.xsl"/>  <!-- named/weird templates -->
<xsl:import href="asset-transformations-omnitest.xsl"/> <!-- matches for assets -->
<xsl:import href="table-transformations.xsl"/> <!-- table transformations -->


<xsl:output method="html" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>

		<xsl:template match="/*:document"> <!-- match a document with any namespace -->	
			
			<xsl:choose>
			<xsl:when test="$ou:action = 'pub' and $ou:publishBlankPages = 'yes'">
				<div><xsl:comment> com.omniupdate.ob </xsl:comment><xsl:comment> /com.omniupdate.ob </xsl:comment></div>
			</xsl:when>
			<xsl:otherwise>
				<!-- begin html -->
				<!-- <xsl:call-template name="server-model" /> -->
				<xsl:text disable-output-escaping="yes">&lt;</xsl:text>!DOCTYPE html<xsl:text disable-output-escaping="yes">&gt;</xsl:text>
				<xsl:text disable-output-escaping="yes">&lt;</xsl:text>html<xsl:text disable-output-escaping="yes"> lang="en" &gt;</xsl:text>
				
					<head>
		
						<xsl:call-template name="common-headcode"/> <!-- common headcode -->
						<xsl:call-template name="template-headcode"/> <!-- template headcode -->
						<!--adds blog javascript to any page with a blog asset, on publish-->
						<xsl:if test="descendant::recent-posts or descendant::featured-posts or descendant::post-tags and $ou:action='pub'">
							<script type="text/javascript" src="/_resources/js/blog/listing.js"></script>
						</xsl:if>
						<xsl:apply-templates select="headcode/node()" mode="copy"/> 
						
						<title><xsl:value-of select="$pageTitle"/></title>
										
						<!-- copy meta tags from pcf, but only those with content -->
						<xsl:for-each select="/*:document/metadata//meta">
							<xsl:if test="string-length(@content)>0">
								<xsl:apply-templates select="." mode="copy"/>
							</xsl:if>
						</xsl:for-each>
						
						<xsl:call-template name="social-meta"/>
		
						
					</head>
					<body>
					<xsl:if test="$bodyClass!='none'"><xsl:attribute name="class" select="$bodyClass"/></xsl:if>		
								
					<xsl:apply-templates select="bodycode/node()" mode="copy"/> <!-- pcf -->
					<!-- start -->
					<noscript>Javascript must be enabled for the correct page display</noscript>
						<div id="wrapper">
							<!-- skip -->
							<xsl:call-template name="common-header"/>
							<!-- main -->
							<xsl:call-template name="page-content"/>
							<!-- footer -->
							<xsl:call-template name="common-footer"/>
							<!-- template footcode -->
							<xsl:call-template name="template-footcode"/>
							
							<!-- skip -->
							<div class="skip">
								<a href="#header">Back to top</a>
							</div>
						</div>
						<xsl:comment> popup-holder </xsl:comment>
								
						<div class="popup-holder">				
							<xsl:call-template name="lightboxes"/><!-- see special-templates.xsl -->					
						</div>
						
					</body>	
					
				<xsl:text disable-output-escaping="yes">&lt;</xsl:text>/html<xsl:text disable-output-escaping="yes">&gt;</xsl:text>	
				<!-- end html -->		
			</xsl:otherwise>
			</xsl:choose>
			
	
		
		</xsl:template>		
			
		<!-- redefine in pagetype xsl as needed -->
		
	<xsl:template name="common-header">
		

			
			<div class="skip">
			<a href="#main" accesskey="S">Skip to content, Accesskey F: Farm &amp; Ranch, Accesskey Y: Yard &amp; Garden, Accesskey B: Business &amp; Communities, Accesskey E: Environment &amp; Nature,Accesskey H: Health &amp; Living, Accesskey 4: 4H &amp; Youth</a>
			</div>
			<!-- header -->
			<header id="header">
				<!-- header-holder -->
				<div class="header-holder">
					<div class="container">
						<!-- header division links: begin -->
						<nav class="header-nav g3">
							<ul>
								<xsl:copy-of select="ou:standardInclude('/_resources/includes/division-nav.inc')"/>
							</ul>
						</nav>
						<!-- header division links: end -->
					</div>
				</div>
				<!-- header-frame -->
				<div class="header-frame">
					<div class="container">
						<!-- header-block -->
						<div class="header-block">
							<!-- auxiliary navigation: begin -->
							<nav class="add-nav">
								<ul>
									<xsl:copy-of select="ou:standardInclude('/_resources/includes/auxiliary-nav.inc')"/>
								</ul>
							</nav>
							<!-- auxiliary navigation: end --> 
							
							<!-- form-block -->
							<div class="form-block">
								<!-- search box -->
								<xsl:copy-of select="ou:standardInclude('/_resources/includes/search-box.inc')"/>
							</div>
						</div>
						<!-- logo -->
						<xsl:copy-of select="ou:standardInclude('/_resources/includes/logo.inc')"/>
						<!-- button-block -->
						<div class="button-block">
							<!-- Share Button:  BEGIN -->
							<xsl:copy-of select="ou:standardInclude('/_resources/includes/share-button.inc')"/>
							<!-- Share Button:  END -->
						</div>
					</div>
				</div>
				<!-- nav-block -->
				<xsl:call-template name="common-top-navigation"/>
			</header>

		</xsl:template>
	
		
	<xsl:template name="common-headcode">
		<xsl:copy-of select="ou:standardInclude('/_resources/includes/headcode.inc')"/>
		<!-- search for any instances of LDP forms or galleries -->
			<xsl:if test="/*:document/content//gallery">
				<xsl:comment>CSS and JS for OU Galleries</xsl:comment>
				<xsl:copy-of select="ou:gallery-headcode($galleryType)" />
			</xsl:if>
			<!-- <xsl:if test="/*:document/content//ouform">
				<xsl:comment>CSS and JS for OU Forms</xsl:comment>
				<link type="text/css" href="/_resources/css/ouforms-bootstrap.css" rel="stylesheet"/>
				<link type="text/css" href="/_resources/css/error-success.css" rel="stylesheet"/>
			</xsl:if> -->
		<xsl:if test="$ou:action!='pub'">
			<link type="text/css" href="/_resources/css/oustaging.css" rel="stylesheet"/>
			<script type="text/javascript">
			var $currentPage = "<xsl:value-of select="concat($domain,$ou:path)"/>";
			var $accessKey = "<xsl:value-of select="$ou:accessKey"/>";
			</script>
		</xsl:if>
		<!-- DirectEdit -->
		<xsl:if test="$ou:action='pub'">
				<script type="text/javascript" src="/_resources/js/directedit.js"></script>
				<script type="text/javascript">
				<xsl:comment><![CDATA[
				window.onload = function(){ directedit(); }
				]]>//</xsl:comment>
				</script>
				<script type="text/javascript">
				var $accessKey = "<xsl:value-of select="$ou:accessKey"/>";
				</script>
		</xsl:if>
		<script type="text/javascript">
		var page_id="<xsl:value-of select="concat(string-join(remove(tokenize(substring($ou:httproot, 1), '/'), count(tokenize(substring($ou:httproot, 1), '/'))), '/'),$ou:path)"/>";
		</script>
		<xsl:copy-of select="ou:standardInclude('/_resources/includes/analytics.inc')"/>
	</xsl:template>
		
		<xsl:template name="common-footer"> 
			<footer id="footer">
				<div class="container">
					<!-- footer-columns -->
					<div class="footer-columns cf"> <!-- Left Column Quick Links -->
						<!-- navigation -->
						<nav class="g1">


								<xsl:copy-of select="ou:standardInclude('/_resources/includes/divisions-footer-left-links.inc')"/>


						</nav>
						<!-- address -->
						<div class="g1">

							<address>
								<xsl:copy-of select="ou:standardInclude('/_resources/includes/divisions-footer-address.inc')"/>
							</address>



							<nav>
								
							</nav>	

						</div>

						<nav class="g1 col-last">											
							<xsl:copy-of select="ou:standardInclude('/_resources/includes/divisions-footer-right-links.inc')"/>
							<xsl:copy-of select="ou:standardInclude('/_resources/includes/divisions-employment.inc')"/>
						</nav>


					</div>
				<br/>
					<nav class="footer-nav">
						<xsl:copy-of select="ou:standardInclude('/_resources/includes/divisions-footer-middle-links.inc')"/>
					</nav>
			</div>
			
			
				<!--adds blog javascript to any page with a blog asset, on publish-->
				<xsl:if test="descendant::recent-posts or descendant::featured-posts or descendant::post-tags and $ou:action='pub'">
					<script type="text/javascript" src="/_resources/js/blog/blog.js"></script>
				</xsl:if>
				<xsl:apply-templates select="footcode/node()" mode="copy"/> <!-- pcf -->	
			</footer>
			<div id="hidden" style="display:none;"><xsl:comment> com.omniupdate.ob </xsl:comment><xsl:comment> /com.omniupdate.ob </xsl:comment></div>
		</xsl:template>
				
		<!-- OUC Dynamic 3rd Level Tagging template match -->
		
		<xsl:variable name="bodyClasses" select="concat($bodyClass,' ',$pageType, ' columns' , $pageColumns)"/>	
		
		<xsl:template match="ouc:div" mode="copy">
			<xsl:choose>
				<!-- Don't write the ouc:div during compare -->
				<xsl:when test="$ou:action='cmp'">
					<xsl:apply-templates select="node()" mode="copy" /> 
				</xsl:when>	
				<xsl:otherwise>
					<!-- Rewrite the tag, its attributes, and add the wysiwyg attribute with the contents bodyClasses variable -->
					<!-- Copy the content following the ouc:div tag, which will then trigger any required template matches  -->
					<ouc:div>
						<xsl:attribute name="wysiwyg-class"><xsl:value-of select="$bodyClasses"/></xsl:attribute>						
						<xsl:apply-templates select="attribute() | node()" mode="copy" />
					</ouc:div>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:template>			
								
		<!-- in case not defined in pagetype xsl -->
		<xsl:template name="page-content"><p>No template defined.</p></xsl:template>
		
    <xsl:template name="common-top-navigation">
        <xsl:choose>
            <xsl:when test="not($ouc:action='pub')">
                 <xsl:value-of select="unparsed-text(concat($ou:httproot,'_resources/includes/top-nav.inc'), 'utf-8')" disable-output-escaping="yes"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:copy-of select="ou:standardInclude('/_resources/includes/top-nav.inc')"/>
            </xsl:otherwise>
        </xsl:choose>
        
    </xsl:template>
	
	<xsl:template name="social-meta">
		<!-- open graph start -->
		<meta property="og:type" content="website"/>
		<meta property="og:title" content="{ouc:properties/title/text()}"/>
		<meta property="og:description" content="{metadata/ouc:properties/meta[@name='Description']/@content}" />
		<meta property="og:url" content="{concat(string-join(remove(tokenize(substring($ou:httproot, 1), '/'), count(tokenize(substring($ou:httproot, 1), '/'))), '/'),$ou:path)}"/>
		<meta property="og:image" content="{$ou:og-image}"/>
		<meta property="og:site_name" content="{ouc:properties/title/text()}"/>
		<meta property="fb:admins" content="{$ou:fb-admins}" />
		<meta property="fb:app_id" content="{$ou:fb-app_id}" />
		<!-- open graph end -->
		<!-- twitter start -->
		<meta name="twitter:card" content="summary"/>
		<meta name="twitter:title" content="{ouc:properties/title/text()}"/>
		<meta name="twitter:description" content="{metadata/ouc:properties/meta[@name='Description']/@content}"/>
		<meta name="twitter:url" content="{concat(string-join(remove(tokenize(substring($ou:httproot, 1), '/'), count(tokenize(substring($ou:httproot, 1), '/'))), '/'),$ou:path)}"/>
		<meta name="twitter:image" content="{$ou:og-image}"/>
		<meta name="twitter:site" content="{$ou:twitter-site}"/>
		<meta name="twitter:creator" value="{$ou:twitter-creator}"/>
		<!-- twitter end -->
	</xsl:template>
	
	<xsl:template name="template-headcode"/>
	<xsl:template name="template-footcode"/>

</xsl:stylesheet>
