﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="HostName" select="normalize-space(AjaxRequest/HostName)"></xsl:variable>
		<xsl:variable name="TemplateURL" select="normalize-space(AjaxRequest/TemplateURL)"></xsl:variable>
		<xsl:variable name="Authenticated" select="normalize-space(AjaxRequest/Authenticated)"></xsl:variable>
		<xsl:variable name="SeletecTab" select="normalize-space(AjaxRequest/Params/SelectedLink)"></xsl:variable>
		<xsl:variable name="DomainName" select="normalize-space(AjaxRequest/Params/DomainName)"></xsl:variable>

		<xsl:variable name="SelectedLink">
			<xsl:choose>
				<xsl:when test="$SeletecTab = ''">
					<xsl:text>goals</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$SeletecTab"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$DomainName = 'happiness'">
				<table id="divWorkingAreaHeader_ActionLink" height="100%" cellspacing="0" cellpadding="0" class="tableMaster smallerFont">
					<tr>
						<xsl:variable name="count" select="7"/>

						<xsl:for-each select="(//*)[position() &lt;= $count]">

							<xsl:variable name="TabName">
								<xsl:choose>
									<xsl:when test="position()=1">
										<xsl:text>home</xsl:text>
									</xsl:when>
									<xsl:when test="position()=2">
										<xsl:text>goals</xsl:text>
									</xsl:when>
									<xsl:when test="position()=3">
										<xsl:text>about</xsl:text>
									</xsl:when>
									<xsl:when test="position()=4">
										<xsl:text>videos</xsl:text>
									</xsl:when>
									<xsl:when test="position()=5">
										<xsl:text>app</xsl:text>
									</xsl:when>
									<xsl:when test="position()=6">
										<xsl:text>store</xsl:text>
									</xsl:when>
									<xsl:when test="position()=7">
										<xsl:text>contact</xsl:text>
									</xsl:when>
								</xsl:choose>
							</xsl:variable>

							<xsl:variable name="DisplayName">
								<xsl:choose>
									<xsl:when test="position()=1">
										<xsl:text>home</xsl:text>
									</xsl:when>
									<xsl:when test="position()=2">
										<xsl:text>goals</xsl:text>
									</xsl:when>
									<xsl:when test="position()=3">
										<xsl:text>about</xsl:text>
									</xsl:when>
									<xsl:when test="position()=4">
										<xsl:text>videos</xsl:text>
									</xsl:when>
									<xsl:when test="position()=5">
										<xsl:text>our app</xsl:text>
									</xsl:when>
									<xsl:when test="position()=6">
										<xsl:text>store</xsl:text>
									</xsl:when>
									<xsl:when test="position()=7">
										<xsl:text>contact</xsl:text>
									</xsl:when>
								</xsl:choose>
							</xsl:variable>

							<xsl:variable name="tabClass">
								<xsl:choose>
									<xsl:when test="$TabName = $SelectedLink">
										<xsl:text>selectedTopHeaderText</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>defaultTopHeaderText</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:variable>

							<xsl:variable name="tabLink">
								<xsl:choose>
									<xsl:when test="$TabName != 'goals' and $TabName != 'Goals'">
										<xsl:text>http://www.thesecretofhappiness.com/</xsl:text>
										<xsl:value-of select="$TabName"/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>http://</xsl:text>
										<xsl:value-of select="$HostName"/>
										<xsl:text>/</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:variable>

							<td id="imgTab_{position()}" nowrap="nowrap" class="verticallyMiddle textCenter">
								<a href="{$tabLink}" class="decorationNone paddingLeft15 paddingRight15 onMouseOver" style="display:block;">
									<div class="{$tabClass}">
										<xsl:value-of select="$DisplayName"/>
									</div>
								</a>
							</td>
						</xsl:for-each>

						<xsl:if test="$Authenticated = 'False'">
							<td class="verticallyMiddle textRight">
								<a href="#">
									<img alt="" src="{$TemplateURL}Web/Images/Ver_2_0/Happiness/app-storebtn.png"></img>
								</a>
							</td>
						</xsl:if>
					</tr>
				</table>
			</xsl:when>
			<xsl:when test="$DomainName = 'core'">
				<table id="divWorkingAreaHeader_ActionLink" height="100%" cellspacing="0" cellpadding="0" class="tableMaster">
					<tr>
						<xsl:variable name="count" select="7"/>

						<xsl:for-each select="(//*)[position() &lt;= $count]">

							<xsl:variable name="TabName">
								<xsl:choose>
									<xsl:when test="position()=1">
										<xsl:text>home</xsl:text>
									</xsl:when>
									<xsl:when test="position()=2">
										<xsl:text>aboutus</xsl:text>
									</xsl:when>
									<xsl:when test="position()=3">
										<xsl:text>events</xsl:text>
									</xsl:when>
									<xsl:when test="position()=4">
										<xsl:text>corereport</xsl:text>
									</xsl:when>
									<xsl:when test="position()=5">
										<xsl:text>blog</xsl:text>
									</xsl:when>
									<xsl:when test="position()=6">
										<xsl:text>store</xsl:text>
									</xsl:when>
									<xsl:when test="position()=7">
										<xsl:text>contactus</xsl:text>
									</xsl:when>
								</xsl:choose>
							</xsl:variable>

							<xsl:variable name="DisplayName">
								<xsl:choose>
									<xsl:when test="position()=1">
										<xsl:text>Home</xsl:text>
									</xsl:when>
									<xsl:when test="position()=2">
										<xsl:text>About Us</xsl:text>
									</xsl:when>
									<xsl:when test="position()=3">
										<xsl:text>Events</xsl:text>
									</xsl:when>
									<xsl:when test="position()=4">
										<xsl:text>C.O.R.E. Report</xsl:text>
									</xsl:when>
									<xsl:when test="position()=5">
										<xsl:text>Blog</xsl:text>
									</xsl:when>
									<xsl:when test="position()=6">
										<xsl:text>Store</xsl:text>
									</xsl:when>
									<xsl:when test="position()=7">
										<xsl:text>Contact Us</xsl:text>
									</xsl:when>
								</xsl:choose>
							</xsl:variable>

							<xsl:variable name="tabClass">
								<xsl:choose>
									<xsl:when test="$TabName = $SelectedLink">
										<!--<xsl:text>selectedTopHeaderTextCore</xsl:text>-->
										<xsl:text>defaultTopHeaderTextCore</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>defaultTopHeaderTextCore</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:variable>

							<!--<xsl:variable name="tabLink">
								<xsl:choose>
									<xsl:when test="$TabName != 'goals' and $TabName != 'Goals'">
										<xsl:text>http://www.thesecretofhappiness.com/</xsl:text>
										<xsl:value-of select="$TabName"/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>http://</xsl:text>
										<xsl:value-of select="$HostName"/>
										<xsl:text>/</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:variable>-->

							<xsl:variable name="borderStyle">
								<xsl:choose>
									<xsl:when test="position()=1">
										<xsl:text>border-right:1px solid #1E3754;border-left:1px solid #1E3754;</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>border-right:1px solid #1E3754;</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:variable>

							<td id="imgTab_{position()}" nowrap="nowrap" class="verticallyMiddle textCenter {$tabClass}" style="{$borderStyle}">
								<a href="#" class="decorationNone paddingLeft15 paddingRight15 paddingTop10 paddingBottom10" style="display:block;">
									<div style="color:#FFFFFF;">
										<xsl:value-of select="$DisplayName"/>
									</div>
								</a>
							</td>
						</xsl:for-each>
					</tr>
				</table>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
