<?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"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xsl xs ou ouc">

	<xsl:import href="dependencies.xsl"/>
	<xsl:import href="footer.xsl" />
	<xsl:include href="snippets.xsl"/>

	<xsl:param name="bodyClass" select="/document/ouc:properties/parameter[@name='theme']/option[@selected='true']/@value" />

	<xsl:output method="xhtml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" include-content-type="no"
		doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />

	<xsl:template match="/document"><!-- begin html -->
		<html xmlns="http://www.w3.org/1999/xhtml">
			<head>
				<xsl:call-template name="headcode"/> <!-- common headcode -->
				<xsl:call-template name="additional-headcode"/> <!-- each pagetype may have a version of this template -->
				<xsl:apply-templates select="headcode/node()"/>
				<title><xsl:value-of select="ouc:properties[@label='metadata']/title"/></title>
				<!-- copy meta tags from pcf, but only those with content -->
				<xsl:apply-templates select="ouc:properties[@label='metadata']/meta[string-length(@content)>0]"/>
			</head>
			<body>
				<table class="body">
					<tr>
						<td class="center" align="center" valign="top">
							<center>
								<xsl:call-template name="header"/>
								<xsl:call-template name="page-content"/> <!-- each pagetype has a unique version of this template -->
								<xsl:call-template name="footer"/>
							</center>
						</td>
					</tr>
				</table>
				<!--Necescary based on the site, otherwise the direct edit button will show up-->
				<div id="hidden" style='display:none;font-size:0px;'><xsl:comment> com.omniupdate.ob </xsl:comment><xsl:comment> /com.omniupdate.ob </xsl:comment></div>
			</body>
		</html>
		<!-- end html -->
	</xsl:template>

	<xsl:template name="headcode">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width"/>

		<style>
			<!-- Include the default INK CSS files (and add any additional base theming includes. -->
			<xsl:copy-of select="ou:includeCSS('/_resources/css/email/base.css')" /><!--Default Email Theme CSS-->
			<xsl:copy-of select="ou:includeCSS('/_resources/css/email/button.css')" /><!-- OU Button Color CSS-->
			<xsl:copy-of select="ou:includeCSS('/_resources/css/email/panels.css')" /><!-- OU Modified CSS for panel styles -->

			<!-- Selecting the custom color theme-->
			<xsl:copy-of select="ou:includeCSS(concat('/_resources/css/email/themes/',ouc:properties/parameter[@name='theme']/option[@selected='true']/@value,'-theme.css'))"/>
		</style>
	</xsl:template>

	<xsl:template name="header">
		<!--View email in browser page property-->
		<xsl:if test="ouc:properties/parameter[@name = 'browser-link']/option[@selected='true']/@value = 'show'">
			<table class="row browser-link">
				<tr>
					<td class="wrapper center">
						<center>
							<table class="container">
								<tr>
									<td>
										<table class="row">
											<tr>
												<td class="wrapper last">
													<table class="twelve columns">
														<tr>
															<td>
																<p class="center"><em>Having trouble viewing this email? Try it in your <webversion>browser</webversion>.</em></p>
															</td>
															<td class="expander"></td>
														</tr>
													</table>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</center>
					</td>
				</tr>
			</table>
		</xsl:if>
		<!--Header logo-->
		<table class="row header">
			<tr>
				<td class="center" align="center">
					<center>
						<table class="container">
							<tr>
								<td class="wrapper last">
									<table class="twelve columns">
										<tr>
											<td class="center">
												<img class="center" src="{ouc:properties/parameter[@name='header-logo']}" alt="Header Logo" />
											</td>
											<td class="expander"></td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</center>
				</td>
			</tr>
		</table>
	</xsl:template>
	<!--Footer - Edited via pcf in includes folder-->
	<!--Needs to be cleaned up more to eliminate unparsed-text-->
	<xsl:template name="footer">
		<xsl:choose>
			<xsl:when test="$ou:action = 'pub'">
				<xsl:copy-of select="ou:includeFile('/_resources/includes/email/footer.inc')"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="footer-display">
					<xsl:with-param name="context" select="document(concat($ou:root,$ou:site,'/_resources/includes/email/footer.pcf'))/document" />
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
		<!--View email disclaimer content controlled via page property-->
		<xsl:if test="ouc:properties/parameter[@name='disclaimer']/option[@value = 'show']/@selected = 'true'">
			<table class="row disclaimer">
				<tr>
					<td class="wrapper center">
						<center>
							<table class="container">
								<tr>
									<td>
										<table class="row">
											<tr>
												<td class="wrapper last">
													<table class="twelve columns">
														<tr>
															<td>
																<xsl:apply-templates select="ouc:div[@label='disclaimer']" />
															</td>
															<td class="expander"></td>
														</tr>
													</table>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</center>
					</td>
				</tr>
			</table>
		</xsl:if>
	</xsl:template>
	<!-- in case not defined in pagetype xsl -->
	<xsl:template name="page-content"><p>No template defined.</p></xsl:template><!-- leave for debugging purposes -->
	<xsl:template name="additional-headcode"/>

</xsl:stylesheet>
