<?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="emp-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.xsl"/> <!-- matches for assets -->
<xsl:import href="emp-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 -->

						<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>
					
						<!-- Ally Website Integration Script -->
<style>
	#ally-af-launcher.ally-af-launch-container {
	  left: 0px !important;
	  width:50px !important;
	  bottom: 55.8px !important;
	}
	  #ally-af-launcher.ally-af-style-flag_small {
	  left: 0px !important;
	  width: 55px !important;
	  bottom: 55.8px !important;
	}
	.ally-af-launch-container.ally-af-style-flag_small>button{
	  border-right: 1px solid #fff !important;
	 }
</style>
						
<script type="text/javascript"><![CDATA[
   var allyLoader = document.createElement('script');
   // Can be flag_small, flag_large or bar_bottom
   allyLoader.setAttribute('data-ally-af-style', 'flag_small');
   allyLoader.setAttribute('data-ally-client-id', ' 10223');
   allyLoader.setAttribute('data-ally-loader', '');
   allyLoader.setAttribute('data-ally-platform-name', 'web');
   allyLoader.setAttribute('src', 'https://prod.ally.ac/integration/api/ally.ui.js');
   document.body.appendChild(allyLoader);
// ]]></script>
						
					<xsl:if test="$bodyClass!='none'"><xsl:attribute name="class" select="$bodyClass"/></xsl:if>		
					<xsl:call-template name="common-header"/>			
					<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 -->
							
							
							<!-- skip -->
						
						</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">

	</xsl:template>	
	
	
		
	<xsl:template name="common-headcode">
		<xsl:copy-of select="ou:standardInclude('/_resources/includes/employee-headcode.inc')"/>
		<!-- <script type="text/javascript" src="/_resources/js/nav_fix.js"></script> -->
		<!-- 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/emp-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>
				<link type="text/css" href="/_resources/css/emp-3imageHover.css" rel="stylesheet" />
				<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: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($ouc:httproot,'_resources/includes/employee-nav.inc'), 'utf-8')" disable-output-escaping="yes"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:copy-of select="ou:standardInclude('/_resources/includes/employee-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: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:site" content="{$ou:twitter-site}"/>
		<meta name="twitter:creator" value="{$ou:twitter-creator}"/>
		<!-- twitter end -->
	</xsl:template>
	
	<xsl:template name="common-footer"> 
		<xsl:copy-of select="ou:standardInclude('/_resources/includes/employee-footer.inc')"/>
							
				<!--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 -->	

			<div id="hidden" style="display:none;"><xsl:comment> com.omniupdate.ob </xsl:comment><xsl:comment> /com.omniupdate.ob </xsl:comment></div>
		</xsl:template>
	
	<xsl:template name="template-headcode"/>
	<xsl:template name="template-footcode"/>

</xsl:stylesheet>
