<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<!--
=============================
COMMMON STYLESHEET 
Imported by all page type-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.
=============================
06/01/2016	-	added ouforms functionality
06/03/2016	-	added section banner functionality 
06/06/2016	-	change h2.page-title to h2.page-title
06/16/2016	-	add mailto: to contact e-mail
-->
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
	xmlns:ouc="http://omniupdate.com/XSL/Variables"
	xmlns:ou="http://omniupdate.com/XSL/Variables" 
	xmlns:fn="http://omniupdate.com/XSL/Functions"
	 exclude-result-prefixes="xsl xs ou fn ouc">

	<!-- Standard Identity & typical transformations -->
	<xsl:import href="_shared/template-matches.xsl"/>

	<xsl:import href="_shared/ouvariables.xsl"/>
	<xsl:import href="_shared/functions.xsl"/>
	<xsl:import href="_shared/breadcrumb.xsl"/>
	<xsl:import href="_shared/ougalleries-42711.xsl"/>
	<xsl:import href="_shared/ou-forms.xsl"/>
	
	<!-- Implementation Specific transformations -->
	<xsl:import href="_shared/special-transformations.xsl"/>

	<!-- Default: for HTML5 use below output declaration -->
	<xsl:output method="html" version="5.0" indent="yes" encoding="UTF-8" include-content-type="no"/>

	<!-- === Root: Global template calls & html structure === -->
	<xsl:template match="/document">
		<!-- begin html -->
		<html lang="en">
			<head>
				<!-- common headcode -->
				<xsl:call-template name="common-headcode"/>
				<!-- each page type may have a version of this template -->
				<xsl:call-template name="template-headcode"/>
				<!-- Gallery Resources -->
				<xsl:if test="ouc:div/descendant::gallery"> 
					<xsl:copy-of select="ou:gallery-headcode()"/>
				</xsl:if>	
				<!-- head content specific to the page -->
				<xsl:apply-templates select="headcode/node()"/>
				<title>
					<xsl:value-of select="concat($page-title, ' | Horry-Georgetown Technical College')"/>
				</title>
				<!-- copy meta tags from pcf, but only those with content -->
				<xsl:apply-templates select="/document/ouc:properties[@label='metadata']/meta[string-length(@content)>0]"/>
			</head>
			<body>
				<xsl:apply-templates select="bodycode/node()"/>
				
				<!-- Added BodyCode Include For Ticket #40939 -->
				<xsl:copy-of select="ou:include-file('/_resources/includes/bodycode.inc')"/>
				
				<!-- pcf -->
				<xsl:call-template name="common-header"/>
				
				<xsl:comment> ou-search-start </xsl:comment>
				<xsl:call-template name="page-content"/>
				<xsl:comment> ou-search-end </xsl:comment>
				
				<!-- each page type has a unique version of this template -->
				<xsl:call-template name="common-footer"/>
				<!-- Gallery Resources -->
				<xsl:if test="ouc:div/descendant::gallery"> 
					<xsl:copy-of select="ou:gallery-footcode()"/>
				</xsl:if>
				<xsl:call-template name="form-footcode"/>
				<!-- Template Specific Resources -->
				<xsl:call-template name="template-footcode" />
				<!-- Page Specific Resources -->
				<xsl:apply-templates select="footcode/node()"/>
				<!-- pcf -->
				<xsl:comment> ousearch-keywords="<xsl:value-of select="$ou:ousearch-keywords" />" </xsl:comment>
			</body>
		</html>
		<!-- end html -->
	</xsl:template>

	<!-- === Headcode: Global JS/CSS === -->
	<xsl:template name="common-headcode">
		<xsl:copy-of select="ou:include-file('/_resources/includes/headcode.inc')"/>
		<script>
			// LDP Comments (Powered by Disqus)
			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:call-template name="form-headcode"/>
	</xsl:template>

	<!-- === Header: call top/middle parts === -->
	<xsl:template name="common-header">
		<!-- HEADER -->
		<header class="siteHeader">
			<!-- top & desktop only features -->
			<xsl:call-template name="common-header-top"/>
			<!-- bottom & mobile only features -->
			<xsl:call-template name="common-header-middle"/>
		</header>
	</xsl:template>

	<!-- === Header: desktop only areas === -->
	<xsl:template name="common-header-top">
		<xsl:param name="group" select="'None'"/>
		<xsl:copy-of select="ou:include-file('/_resources/includes/header-skip.inc',$group)"/>
		<xsl:call-template name="unparsed-on-staging">
			<xsl:with-param name="path">/_resources/includes/emergency-alert.inc</xsl:with-param>
		</xsl:call-template>
		<nav class="navbar navbar-default auxnav hidden-xs">
			<div class="container-fluid">
				<!-- Auxillary Navigation -->
				<div class="collapse navbar-collapse">
					<!-- Top gray links (aux-nav) -->
					<xsl:copy-of select="ou:include-file('/_resources/includes/header-top-links.inc',$group)"/>
					<ul class="nav navbar-nav navbar-right">
						<!-- phone/chat links -->
						<xsl:copy-of select="ou:include-file('/_resources/includes/header-phone-chat.inc',$group)"/>
						<li class="dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Quicklinks <span class="caret"/></a>
							<ul class="dropdown-menu">
								<!-- quicklinks -->
								<xsl:copy-of select="ou:include-file('/_resources/includes/header-quick-links.inc',$group)"/>
							</ul>
						</li>
					</ul>
					<!-- 06/02/2016	-	add missing search include -->
					<xsl:copy-of select="ou:include-file('/_resources/includes/header-search.inc',$group)"/>
				</div>
				<!-- /.navbar-collapse -->
			</div>
			<!-- /.container-fluid -->
		</nav>
		<div class="white-line hidden-xs">
			<xsl:comment/>
		</div>
		<div class="container-fluid">
			<div class="row mid-header">
				<div class="col-xs-12 col-sm-7">
					<a href="#siteNavigation" class="menuToggle btn btn-default visible-xs" role="button">Menu</a>
					<!-- School Logo -->
					<xsl:copy-of select="ou:include-file('/_resources/includes/header-logo.inc',$group)"/>
				</div>
				<div class="col-xs-12 col-sm-5">
					<!-- WaveNet login & logo -->
					<div class="wavenet hidden-xs">
						<xsl:copy-of select="ou:include-file('/_resources/includes/header-wavenet.inc',$group)"/>
					</div>
				</div>
			</div>
			<!-- Apply/Request Info/Visit Buttons -->
			<div class="headerButtons hidden-xs">
				<xsl:copy-of select="ou:include-file('/_resources/includes/header-buttons.inc',$group)"/>
			</div>
		</div>
	</xsl:template>

	<!-- === Header: Bottom & mobile only areas === -->
	<xsl:template name="common-header-middle">
		<nav class="navbar siteNavigation" id="siteNavigation" aria-label="Primary navigation">
			<a href="#" class="menuClose visible-xs">Close Menu</a>
			<div class="visible-xs">
				<ul class="nav navbar-nav navbar-right">
					<xsl:copy-of select="ou:include-file('/_resources/includes/header-phone-chat.inc','None','header-xs-phone-chat')"/>
				</ul>
				<!-- 06/02/2016	-	add missing search include -->
				<xsl:copy-of select="ou:include-file('/_resources/includes/header-search.inc','None','header-xs-search')"/>
			</div>
			<xsl:call-template name="unparsed-on-staging">
				<xsl:with-param name="path">/_resources/includes/header-mega-nav.inc</xsl:with-param>
			</xsl:call-template>
			<ul class="nav navbar-nav auxnav visible-xs">
				<xsl:copy-of select="ou:include-file('/_resources/includes/header-top-links.inc','None')"/>
			</ul>
			<div class="row visible-xs nav-social">
				<xsl:call-template name="unparsed-on-staging">
					<xsl:with-param name="path">/_resources/includes/footer-social-contact.inc</xsl:with-param>
				</xsl:call-template>
			</div>
		</nav>
	</xsl:template>

	<!-- === Page Header: Banner region and title for interior pages === -->
	<xsl:template name="page-header" expand-text="yes">
		<!-- booleans -->
		<xsl:param name="show-banner" select="contains($page-banner-toggle,'image') or ($ou:section-banner-option = 'use-directory' and $ou:section-banner-image!='')" as="xs:boolean"/>
		<xsl:param name="show-caption"  select="contains($page-banner-toggle,'caption') or ($ou:section-banner-option = 'use-directory' and $ou:section-banner-caption!='')" as="xs:boolean"/>
		<xsl:param name="show-gallery" select="$page-banner-toggle = 'gallery' and not(($ou:section-banner-option = 'use-directory' and $ou:section-banner-image!=''))" as="xs:boolean"/>
		<xsl:param name="show-facebook" select="$social-options[.='facebook']!=''" as="xs:boolean"/>
		<xsl:param name="show-twitter" select="$social-options[.='twitter']!=''" as="xs:boolean"/>
		<xsl:param name="overwrite-image" select="$ou:section-banner-option='use-directory' or $page-banner-image=''" as="xs:boolean"/>
		
		<xsl:comment> skip-search-start </xsl:comment>
		
		<xsl:if test="$show-gallery">
			<xsl:copy-of select="ouc:get-edit-button(ouc:div[@label='gallery'])"/>			
		</xsl:if>
		
		<section>
			<div class="header-block-wrapper">
				<xsl:if test="$ou:banner-color!='' and not($ou:banner-color='default')">
					<xsl:attribute name="class">header-block-wrapper-<xsl:value-of select="$ou:banner-color"/></xsl:attribute>
				</xsl:if>
				<div class="container">
					<div class="row">
						<div class="col-xs-9 col-md-10">
							<h1 class="page-title">{$page-heading}</h1>
							<!-- breadcrumbs -->
							<xsl:call-template name="breadcrumb">
								<xsl:with-param name="path" select="$ou:dirname"/>
							</xsl:call-template>
						</div>
						<xsl:if test="$show-facebook or $show-twitter">
							<div class="col-xs-3 col-md-2">
								<ul class="shareButtons">
									<xsl:if test="$show-facebook">
										<!-- global code for facebook like -->
										<xsl:copy-of select="ou:include-file('/_resources/includes/page-header-facebook.inc')"/>
									</xsl:if>
									<xsl:if test="$show-twitter">
										<!-- global code for twitter like -->
										<xsl:copy-of select="ou:include-file('/_resources/includes/page-header-twitter.inc')"/>
									</xsl:if>
								</ul>
							</div>
						</xsl:if>
					</div>
				</div>
			</div>
			<xsl:choose>
				<!-- Should display Banner as gallery -->
				<xsl:when test="$show-gallery">
					<xsl:apply-templates select="ouc:div[@label='gallery']/descendant::gallery">
						<xsl:with-param name="gallery-type">carousel-banner</xsl:with-param>
					</xsl:apply-templates>
				</xsl:when>
				<!-- Should display Banner Image -->
				<xsl:when test="$show-banner">				
					<div class="container-fluid section-image">
						<div class="row">
							<!-- 06/03/2016	-	set banners to section variables when appropriate -->
							<xsl:variable name="src"
								select="
								if($ou:section-banner-option='use-directory' or $page-banner-image='')
								then($ou:section-banner-image)
								else($page-banner-image)
								"/>
							<xsl:variable name="alt"
								select="
								if($ou:section-banner-option='use-directory' or $page-banner-alt='')
								then($ou:section-banner-alt)
								else($page-banner-alt)
								"/>
							<xsl:variable name="caption"
								select="
								if($ou:section-banner-option='use-directory' or $page-banner-caption='')
								then($ou:section-banner-caption)
								else($page-banner-caption)
								"/>
							<img src="{$src}" alt="{$alt}"/>
							<xsl:if test="$show-caption">
								<div class="section-image-caption">
									<xsl:value-of select="$caption"/>
								</div>
							</xsl:if>
						</div>
					</div>
				</xsl:when>
				<!-- Should not display Banner Image -->
				<xsl:otherwise>
					<div class="container-fluid section-image no-image">
						<div class="row"><xsl:comment/></div>
					</div>  
				</xsl:otherwise>
			</xsl:choose>
		</section>
		
		<xsl:comment> skip-search-end </xsl:comment>
	</xsl:template>
	
	<!-- === Left Sidebar: call navigation + contact box for interior pages ===-->
	<xsl:template name="sidebar" expand-text="yes">
		<!-- data -->
		<xsl:param name="section-link" select="$ou:dirname" as="xs:string"/>
		<!-- booleans -->
		<xsl:param name="show-contact" select="string-join($contact-toggle)!=''" as="xs:boolean"/>
		<xsl:param name="show-contact-email" select="$contact-toggle[.='e-mail']!=''" as="xs:boolean"/>
		<xsl:param name="show-contact-phone" select="$contact-toggle[.='phone']!=''" as="xs:boolean"/>
		<xsl:param name="show-contact-need-help" select="$contact-toggle[.='need-help']!=''" as="xs:boolean"/>
		
<!-- 		Removed Chat Live per ticket #40459 -->
<!-- 		<xsl:param name="show-contact-chat-live" select="$contact-toggle[.='chat-live']!=''" as="xs:boolean"/>
 -->
		<!-- to do: navigation 
<xsl:call-template name="sidebar-navigation"/>-->

		<!-- mobile menu for navigation -->
		<xsl:comment> skip-search-start </xsl:comment>

		<p class="visible-xs">
			<button type="button" class="btn btn-default" data-toggle="collapse" data-target=".navbar2-collapse">
				Navigate this Section
				<span class="fa fa-chevron-down"><xsl:comment/></span>
			</button>
		</p>
		<xsl:call-template name="sidebar-navigation" />
		<xsl:if test="$show-contact">
			<div class="contact-box">
				<h2>Contact Us</h2>
				<xsl:if test="$show-contact-email or $show-contact-phone">
					<p>
						<xsl:if test="$show-contact-email">
							<a href="mailto:{$contact-email}">
								<span class="fa fa-envelope" aria-hidden="true">
									<span class="sr-only">Email</span>
								</span>
							</a>
						</xsl:if>
						<xsl:if test="$show-contact-phone">
							<a href="tel:{ou:phone-to-dashes($contact-phone)}">{$contact-phone}</a>
						</xsl:if>
					</p>
				</xsl:if>
				
				<!-- 		Removed Chat Live per ticket #40459 -->
<!-- 				<xsl:if test="$show-contact-chat-live or $show-contact-need-help"> -->
						<xsl:if test="$show-contact-need-help">
					<ul class="circle-icons-list">
						<xsl:if test="$show-contact-need-help">
							<li class="dark-blue"><a href="{if($contact-need-help!='' and $contact-need-help!='#') then($contact-need-help) else($ou:help-link)}"><span class="fa fa-question" aria-hidden="true"><xsl:comment/></span>Need Help?</a></li>									
						</xsl:if>
<!-- 						<xsl:if test="$show-contact-chat-live">
							<li class="dark-blue"><a onclick="chatFunction()" href="{$contact-chat-live}"><span class="fa fa-comment" aria-hidden="true"><xsl:comment/></span>Chat Live</a></li>
						</xsl:if> -->
					</ul>
				</xsl:if>				
			</div>
		</xsl:if>
		<xsl:apply-templates select="ouc:div[@label='sidebar']"/>
		
		<xsl:comment> skip-search-end </xsl:comment>
	</xsl:template>

	<!-- === Left Sidebar: Navigation === -->
	<xsl:template name="sidebar-navigation">
		<xsl:variable name="sidebar-restart" select="ou:find-prev-dir($dirname) = '/' or ou:pcf-param('navigation', $props-doc) = 'restart'" />
		<xsl:variable name="sidebar-path" select="if ($sidebar-restart) then $dirname else ou:find-prev-dir($dirname)" />
		<nav class="collapse navbar-collapse sidenav navbar2-collapse">
			<!-- Section Heading and Link -->
			<!-- Use try/catch in case props PCF is missing -->
			<xsl:try>
				<div class="menuheader">
					<a href="{$sidebar-path}"><xsl:value-of select="if ($sidebar-restart) then $navigation-title else ou:pcf-param('navigation-title', document(concat($ou:root, $ou:site, $sidebar-path, $props-file)))"/></a>
					<!-- section link -->
				</div>
				<xsl:catch/>
			</xsl:try>
			<!-- Section Navigation -->
			<ul class="nav nav-stacked">
				<xsl:if test="not($sidebar-restart)">
					<xsl:attribute name="id">subnav_parent</xsl:attribute>
				</xsl:if>
				<xsl:copy-of select="ou:include-file(concat($sidebar-path, $nav-file))" />
			</ul>
			<xsl:if test="not($sidebar-restart)">
				<ul id="subnav_child" style="display:none;">
					<xsl:copy-of select="ou:include-file(concat($dirname, $nav-file))" />
				</ul>
			</xsl:if>
		</nav>
	</xsl:template>

	<!-- === Page Subfooter: gray page-level footer === -->
	<xsl:template name="sub-footer">
		<!-- page params -->		
		<xsl:param name="settings" select="ou:pcf-param('sub-footer')"/>
		<xsl:if test="$settings!='hide'">
			<section>
				<div class="sub-footer">
					<div class="container">
						<div class="row">							
							<div class="col-md-8{if($settings = 'semester-info') then(' semester-info') else()}">							
								<xsl:apply-templates select="ouc:properties/parameter[@name='subfooter-widget-1']" mode="display-widget"/>
								<xsl:apply-templates select="ouc:properties/parameter[@name='subfooter-widget-2']" mode="display-widget"/>
								<xsl:apply-templates select="ouc:div[@label='sub-footer-left']"/>							
							</div>																														
							<xsl:apply-templates select="ouc:properties/parameter[@name='subfooter-widget-3']" mode="display-widget"/>							
							<xsl:apply-templates select="ouc:div[@label='sub-footer-right']"/>
						</div>
					</div>
				</div>
			</section>			
		</xsl:if>
	</xsl:template>

	<!-- === Footer: Includes for footer html and js === -->
	<xsl:template name="common-footer">
		<xsl:call-template name="unparsed-on-staging">
			<xsl:with-param name="path">/_resources/includes/footer.inc</xsl:with-param>
		</xsl:call-template>
		
		<script>
			// Navigation Variables
			var ou_path = "<xsl:value-of select="$ou:path" />";
			var ou_child = "<xsl:value-of select="$dirname" />";
			var ou_index = "<xsl:value-of select="concat($index-file, '.', $extension)" />";
		</script>
		<xsl:copy-of select="ou:include-file('/_resources/includes/footcode.inc')"/>
		<xsl:copy-of select="ou:include-file('/_resources/includes/analytics.inc')"/>
		<div id="hidden" style="display:none;">
			<xsl:comment> com.omniupdate.ob </xsl:comment>
			<xsl:comment> /com.omniupdate.ob </xsl:comment>
		</div>
	</xsl:template>

	<!-- === Page Level Templates - in case not defined in page type xsl === -->
	<xsl:template name="page-content">
		<p>No template defined.</p>
	</xsl:template>	
	<xsl:template name="template-headcode"/>
	<xsl:template name="template-footcode"/>

</xsl:stylesheet>
