﻿<?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="TemplateURL" select="normalize-space(AjaxRequest/TemplateURL)"></xsl:variable>
        <xsl:variable name="HostName" select="normalize-space(AjaxRequest/HostName)"></xsl:variable>
        <xsl:variable name="DomainName" select="normalize-space(AjaxRequest/Params/DomainName)"></xsl:variable>
        <xsl:variable name="MBrandID" select="normalize-space(AjaxRequest/Params/MBrandID)"></xsl:variable>
        <xsl:variable name="MBrandItemID" select="normalize-space(AjaxRequest/Params/MBrandItemID)"></xsl:variable>
        <xsl:variable name="IsAuthenticate" select="normalize-space(AjaxRequest/Authenticated)"></xsl:variable>
        <xsl:variable name="Origin" select="normalize-space(AjaxRequest/Params/Origin)"></xsl:variable>
        <xsl:variable name="LoginPageLogo" select="AjaxRequest/Settings/Logo/LoginPageLogoURL"></xsl:variable>
        <xsl:variable name="IsSecureConnection" select="AjaxRequest/IsSecureConnection"></xsl:variable>
      <xsl:variable name="DisplayFormat" select="AjaxRequest/DisplayFormatID"></xsl:variable>
      <xsl:variable name="ContentTitle" select="AjaxRequest/ContentTitle"></xsl:variable>
      <xsl:variable name="SettingsData" select="AjaxRequest/Settings/."></xsl:variable>
      <xsl:variable name="TextColor">
        <xsl:choose>
          <xsl:when test="$SettingsData/DefaultTextColor">
            <xsl:value-of select="$SettingsData/DefaultTextColor"/>
          </xsl:when>
          <xsl:otherwise>
            white;
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
        <xsl:variable name="SearchBarDisplayStyle">
            <xsl:choose>
                <xsl:when test="normalize-space(AjaxRequest/Settings/SearchBoxYN) = 'True'">
                    display:block;
                </xsl:when>
                <xsl:otherwise>
                    display:none;
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="LogoURL">
            <xsl:choose>
                <xsl:when test="normalize-space(AjaxRequest/Settings/Logo/LogoURL) != ''">
                    <xsl:value-of select="normalize-space(AjaxRequest/Settings/Logo/LogoURL)"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$TemplateURL"/>
                    <xsl:text>/Web/Images/Ver_2_0/logo.png</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="LogoHeight">
          <xsl:if test="$DisplayFormat=2">
            <xsl:value-of select="30"/>
          </xsl:if>
            <xsl:if test="normalize-space(AjaxRequest/Settings/Logo/LogoHeight) != '' and normalize-space(AjaxRequest/Settings/Logo/LogoHeight) != '0' and $DisplayFormat!=2">
                <xsl:value-of select="normalize-space(AjaxRequest/Settings/Logo/LogoHeight)"/>
            </xsl:if>
        </xsl:variable>

        <xsl:variable name="divTopPageBarClass">
            <xsl:choose>
                <xsl:when test="$DomainName = 'happiness'">
                    <xsl:text>happinessWorkingArea</xsl:text>
                </xsl:when>
                <xsl:when test="(($DomainName = 'localhost' or $DomainName = 'lifespace' or $DomainName = 'lifespacepro' or $DomainName = 'coaching') and $IsAuthenticate = 'False') or
						  (($DomainName = 'localhost' or $DomainName = 'lifespace' or $DomainName = 'lifespacepro' or $DomainName = 'coaching') and $IsAuthenticate = 'True' and 
							($Origin = 'loginls' or $Origin = 'startagoal' or $Origin = 'goalplans' or $Origin = 'yoursuperpage' or 
							 $Origin = 'getconnected' or $Origin = 'getyours' or $Origin = 'template' or $Origin = 'lifespace'))">

                    <xsl:text>lifeSpaceWorkingAreaSmall</xsl:text>
                </xsl:when>
                <xsl:when test="$DomainName = 'vaco' or $DomainName = 'core'">
                    <xsl:text>vacoWorkingArea</xsl:text>
                </xsl:when>
                <xsl:when test="normalize-space(AjaxRequest/Settings/BodyCellNumber) = 1">
                    <xsl:text>vacoWorkingArea</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>lifeSpaceWorkingAreaFull</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="cellLogoTopPageBarClass">
            <xsl:choose>
                <xsl:when test="$DomainName = 'happiness'">
                    <xsl:text>leftBarHappiness textCenter verticallyTop</xsl:text>
                </xsl:when>
                <xsl:when test="$DomainName = 'vaco' or $DomainName = 'core'">
                    <xsl:text>leftBarDragon verticallyMiddle</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:choose>
                    <xsl:when test="$DisplayFormat=2">
                      <xsl:text>logoCell leftMiniBar</xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:text>leftBar logoCell</xsl:text>
                    </xsl:otherwise>
                  </xsl:choose>


                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="TagLineClass">
            <xsl:choose>
                <xsl:when test="normalize-space(AjaxRequest/Settings/TagLineClass)">
                    <xsl:value-of select="normalize-space(AjaxRequest/Settings/TagLineClass)"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>labelLSTagLine</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="Protocol">
            <xsl:choose>
                <xsl:when test="$IsSecureConnection = 1">
                    <xsl:text>https</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>http</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
      <center>
            <div id="divTopPageBar" class="{$divTopPageBarClass}">
                <xsl:choose>
                    <xsl:when test="$DomainName = 'happiness'">
                        <table cellpadding="0" cellspacing="0" width="100%" height="100%" class="paddingBottom5"
                                           style="background-image:url('{$TemplateURL}web/images/ver_2_0/happiness/checkers.png');">
                            <tr>
                                <td id="cellLogoTopPageBar" class="{$cellLogoTopPageBarClass}">
                                    <div align="center">
                                        <div style="width:138px;">
                                            <div style="position: relative; z-index: 200;">
                                                <img border="0" alt="" src="{$TemplateURL}web/images/ver_2_0/happiness/menuHeader.png"
                                                                            onmouseover="document.getElementById('divSubmenuHappiness').style.display='block';" ></img>
                                            </div>
                                            <div style="display: none;" id="divSubmenuHappiness">
                                                <div style="background-image: url('{$TemplateURL}web/images/Ver_2_0/happiness/menuOpenBackground.png');height: 601px;
													 position: absolute;top:-4px;z-index:199;width:139px;">
                                                    <ul class="submenu1">
                                                        <li>
                                                            <a class="about" href="http://thesecretofhappiness.com/about" target="_blank"></a>
                                                        </li>
                                                        <li>
                                                            <a class="goal" href="{$Protocol}://{$HostName}"></a>
                                                        </li>
                                                        <li>
                                                            <a class="ourapp" href="http://thesecretofhappiness.com/store_apps" target="_blank"></a>
                                                        </li>
                                                        <li>
                                                            <a class="newsletter" id="freenewsletterheader" href="#" target="_blank"></a>
                                                        </li>
                                                        <li>
                                                            <a class="store" href="http://thesecretofhappiness.com/store_books" target="_blank"></a>
                                                        </li>
                                                        <li>
                                                            <a class="blog" href="http://blog.thesecretofhappiness.com" target="_blank"></a>
                                                        </li>
                                                        <li>
                                                            <a class="contact" href="http://thesecretofhappiness.com/contact" target="_blank"></a>
                                                        </li>
                                                        <li>
                                                            <a class="submit" href="http://thesecretofhappiness.com/submit" target="_blank"></a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <script language="javascript" type="text/javascript">
                                        document.onclick = function(event) {
                                        if(document.getElementById('divSubmenuHappiness')!=null)
                                        if(document.getElementById('divSubmenuHappiness').style.display=='block')
                                        {
                                        document.getElementById('divSubmenuHappiness').style.display = "none";
                                        }
                                        }
                                    </script>
                                </td>
                                <td id="LoginControlContainer" nowrap="nowrap" class="verticallyMiddle textRight">
                                    <div class="paddingRight20 marginTop20">
                                        <a id="anLifeSpaceHeader" href="{$Protocol}://{$HostName}/">
                                            <img border="0" id="img_Item_logo" alt="" class="verticallyMiddle"  height="{$LogoHeight}" src="{$LogoURL}"></img>
                                        </a>
                                   
                                    </div>
                                    <xsl:choose>
                                        <xsl:when test="$IsAuthenticate = 'False'">
                                            <div id="divLoginControlContainer" class="paddingRight20">
                                                <a class="decorationNone" href="http://www.facebook.com/TheSecretOfHappinessNow" target="_blank">
                                                    <img border="0" src="{$TemplateURL}web/images/ver_2_0/happiness/FB.png" alt=""></img>
                                                </a>
                                                <a class="decorationNone" href="https://twitter.com/1happytweet" target="_blank">
                                                    <img border="0" src="{$TemplateURL}web/images/ver_2_0/happiness/Tw.png" alt=""></img>
                                                </a>
                                                <a class="decorationNone" href="http://thesecretofhappiness.com/contact" target="_blank">
                                                    <img border="0" src="{$TemplateURL}web/images/ver_2_0/happiness/EM.png" alt=""></img>
                                                </a>
                                            </div>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <div id="divLoginControlContainer" class="paddingRight20 onMouseOver"></div>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </td>
                            </tr>
                            <xsl:if test="$IsAuthenticate = 'False' and $Origin = 'loginls'">
                                <tr>
                                    <td colspan="2">
                                        <div align="right" class="paddingBottom15">
                                            <div align="" class="paddingTop10 textLeft" style="width:840px;">
                                                <div class="capitalFont happinessBeginGoals">Begin WITH GOALS</div>
                                                <div class="capitalFont happinessSetGoals marginTop5">it is time to set goals in a fun and interactive way.</div>
                                                <div class="marginTop8">
                                                    <span class="capitalFont happinessGoals verticallyMiddle">it's free, sign up now!</span>
                                                    <img border="0" alt="" onclick="DisplaySignUpPopUp('signup','brandloginregister','0')" class="verticallyMiddle onMouseOver"
                                                                                   src="{$TemplateURL}web/images/ver_2_0/happiness/arrowRight.png"></img>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </xsl:if>
                        </table>
                    </xsl:when>
                    <xsl:otherwise>
                        <table cellpadding="0" cellspacing="0" width="100%" >
                            <tr>
                                <td id="cellLogoTopPageBar" class="{$cellLogoTopPageBarClass}">
                                
                                    <xsl:choose>
                                        <xsl:when test="($DomainName != 'massimo' and $DomainName != 'massimobile')">
                                            <a id="anLifeSpaceHeader" href="{$Protocol}://{$HostName}/">
                                                <xsl:choose>
                                                    <xsl:when test="$LogoHeight != '' and $LogoHeight != 0">
                                                        <img id="img_Item_logo" border="0" src="{$LogoURL}" height="{$LogoHeight}"/>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <img id="img_Item_logo" border="0" src="{$LogoURL}"/>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </a>
                                        </xsl:when>
                                        <xsl:when test="($DomainName = 'massimo' or $DomainName = 'massimobile') and $IsAuthenticate = 'False'">
                                            <a id="anLifeSpaceHeader" href="{$Protocol}://{$HostName}/">
                                                <img id="img_Item_logo" border="0" src="{$LoginPageLogo}"/>
                                            </a>
                                        </xsl:when>
                                    </xsl:choose>
                                  <xsl:if test="$DisplayFormat=2">
                                    <span class="label" style="color: {$TextColor};margin-left: 5%;">
                                      <xsl:value-of select="$ContentTitle"/>
                                    </span>
                                  </xsl:if>
                                 
                                </td>
                                <td id="cellBodyTopPageBar" class="rightBarSmall verticallyMiddle" align="right"
                                                    style="padding-left: 25px;">
                                    <table class="tableMaster" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td id="LSTagLine" width="50%" align="left" class="verticallyMiddle" nowrap="nowrap">
                                                <xsl:choose>
                                                    <xsl:when test="($DomainName = 'massimo' or $DomainName = 'massimobile') and $IsAuthenticate = 'True'">
                                                        <div align="center">
                                                            <a id="anLifeSpaceHeader" href="{$Protocol}://{$HostName}/">
                                                                <xsl:choose>
                                                                    <xsl:when test="$LogoHeight != '' and $LogoHeight != 0">
                                                                        <img id="img_Item_logo" border="0" src="{$LogoURL}" height="{$LogoHeight}"/>
                                                                    </xsl:when>
                                                                    <xsl:otherwise>
                                                                        <img id="img_Item_logo" border="0" src="{$LogoURL}"/>
                                                                    </xsl:otherwise>
                                                                </xsl:choose>
                                                            </a>
                                                        </div>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <div class="{$TagLineClass}" id="divLSTagLine">
                                                            <xsl:choose>
                                                                <xsl:when test="AjaxRequest/Settings/TagLine">
                                                                    <xsl:value-of select="normalize-space(AjaxRequest/Settings/TagLine)" disable-output-escaping="yes"/>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <span class="padding3">Dream.</span>
                                                                    <span class="padding3">Set.</span>
                                                                    <span class="padding3">Track.</span>
                                                                    <span class="padding3">Share.</span>
                                                                    <span class="padding3">Achieve.</span>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </div>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </td>
                                            <td width="10%">
                                                <xsl:if test="AjaxRequest/Settings/GoogleTranslate = 1 and $IsAuthenticate = 'True'">
                                                    <div id="google_translate_element"></div>
                                                    <script type="text/javascript">
                                                        function googleTranslateElementInit()
                                                        {
                                                        new google.translate.TranslateElement
                                                        (
                                                        {pageLanguage: 'en'
                                                        , layout: google.translate.TranslateElement.InlineLayout.SIMPLE
                                                        , multilanguagePage: true, gaTrack: true, gaId: 'UA-119246-44'
                                                        }
                                                        , 'google_translate_element'
                                                        );
                                                        }
                                                    </script>
                                                    <script type="text/javascript"
                                                            src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit">
                                                    </script>
                                                </xsl:if>
                                            </td>
                                            <td width="10%" id="LoginControlContainer" nowrap="nowrap" class="labelHeader verticallyMiddle textRight">
                                                <div id="divLoginControlContainer" class="onMouseOver marginRight6">
                                                </div>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </xsl:otherwise>
                </xsl:choose>
            </div>
        </center>
    </xsl:template>
</xsl:stylesheet>
