﻿<?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:import href="LifeSpaceHeader.xslt"/>
    <xsl:import href="SelectedGoalTitle.xslt"/>
    <xsl:import href="Version_2_0/WorkingAreaHeader.xslt"/>
    <xsl:import href="Modules/WorkoutTracker/ClientContactDetail.xslt"/>

    <xsl:template match="/">
    
        <xsl:variable name="ItemType">
            <xsl:choose>
                <xsl:when test="AjaxRequest/ClientContactDetail/Item/ItemType">
                    <xsl:value-of select="AjaxRequest/ClientContactDetail/Item/ItemType"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="normalize-space(AjaxRequest/Params/ItemType)"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="PermissionID" select="normalize-space(AjaxRequest/Params/PermissionID)"></xsl:variable>
        <xsl:variable name="PortalItemID" select="normalize-space(AjaxRequest/Params/PortalItemID)"></xsl:variable>
        <xsl:variable name="ClientUserID" select="normalize-space(AjaxRequest/Params/ClientUserID)"></xsl:variable>
        <xsl:variable name="HostName" select="normalize-space(AjaxRequest/HostName)"></xsl:variable>
        <xsl:variable name="LoginYN" select="normalize-space(AjaxRequest/LoginYN)"></xsl:variable>
        <xsl:variable name="Origin" select="normalize-space(AjaxRequest/Params/Origin)"></xsl:variable>
        <xsl:variable name="SettingsData" select="AjaxRequest/Settings/."></xsl:variable>
        <xsl:variable name="ContentStatusID" select="normalize-space(AjaxRequest/Params/StatusID)"></xsl:variable>
        <xsl:variable name="IsSecureConnection" select="AjaxRequest/IsSecureConnection"></xsl:variable>
      <xsl:variable name="DisplayFormatID" select="AjaxRequest/Output/DisplayFormatID"></xsl:variable>
    

        <xsl:choose>
            <xsl:when test="$ItemType = 'LifeSpace' and $PermissionID &gt;= 4">
                <xsl:call-template name="LifeSpaceHeader">
                    <xsl:with-param name="TemplatePathURL" select="normalize-space(AjaxRequest/TemplateURL)"></xsl:with-param>
                    <xsl:with-param name="ItemID" select="normalize-space(AjaxRequest/Params/ItemID)"></xsl:with-param>
                    <xsl:with-param name="ItemName" select="normalize-space(AjaxRequest/Params/ItemName)"></xsl:with-param>
                    <xsl:with-param name="PermissionID" select="normalize-space(AjaxRequest/Params/PermissionID)"></xsl:with-param>                 
                </xsl:call-template>
            </xsl:when>

            <xsl:when test="($ItemType = 'None' or $ItemType = 'Project' or $ItemType = 'Goal' or $ItemType = 'Portal' or $ItemType = 'Community' 
                     or $ItemType = 'Template' or $ItemType = 'LSPublication') or $Origin = 'TopMenuBrand' or $Origin = 'content'">
                <xsl:call-template name="WorkingAreaHeader">
                    <xsl:with-param name="TemplatePathURL" select="normalize-space(AjaxRequest/TemplateURL)"></xsl:with-param>
                    <xsl:with-param name="HostName" select="normalize-space(AjaxRequest/HostName)"></xsl:with-param>
                    <xsl:with-param name="UserName" select="AjaxRequest/Params/LoggedInUserDetail/User/UserData/DisplayName"></xsl:with-param>
                    <xsl:with-param name="PicUrl" select="AjaxRequest/Params/LoggedInUserDetail/User/UserData/FbPicURL"></xsl:with-param>
                    <xsl:with-param name="UserID" select="AjaxRequest/Params/LoggedInUserDetail/User/UserData/UserID"></xsl:with-param>
                    <xsl:with-param name="ItemType" select="$ItemType"></xsl:with-param>
                    <xsl:with-param name="ItemID" select="normalize-space(AjaxRequest/Params/ItemID)"/>
                    <xsl:with-param name="Origin" select="normalize-space(AjaxRequest/Params/Origin)"/>
                    <xsl:with-param name="LoginYN" select="$LoginYN"/>
                    <xsl:with-param name="BrandTabID" select="normalize-space(AjaxRequest/Params/BrandTabID)"/>
                    <xsl:with-param name="DomainName" select="normalize-space(AjaxRequest/Brand/DomainName)"/>
					<xsl:with-param name="DisplayFormatID" select="$DisplayFormatID"></xsl:with-param>
                    <xsl:with-param name="PermissionID">
                        <xsl:choose>
                            <xsl:when test="normalize-space(AjaxRequest/Params/Origin) = 'TopMenuBrand'">
                                <xsl:choose>
                                    <xsl:when test="AjaxRequest/Brand/Permission/PermissionID">
                                        <xsl:value-of select="normalize-space(AjaxRequest/Brand/Permission/PermissionID)"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:number value="-1"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="normalize-space(AjaxRequest/Params/PermissionID)"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                    <xsl:with-param name="UserRoles" select="AjaxRequest/UserRoles/."></xsl:with-param>
                    <xsl:with-param name="SettingsData" select="$SettingsData"></xsl:with-param>
                    <xsl:with-param name="ContentStatusID" select="$ContentStatusID"></xsl:with-param>
                    <xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
                 
                    <!--BrandTabID, DomainName is passed only in case of TopMenuBrand-->
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$ItemType = 'Tournament'">
                <table class="selectedTopMenuLink tableMaster">
                    <tr>
                        <td class="textLeft">
                            <xsl:value-of select="AjaxRequest/Params/TournamentDetail/Tournament/Name"/>
                            <xsl:text> @ </xsl:text>
                            <xsl:value-of select="AjaxRequest/Params/TournamentDetail/Tournament/TournamentTime"/>
                        </td>
                        <td class="textRight">
                            <xsl:value-of select="AjaxRequest/Params/TournamentDetail/Tournament/BrandName"/>
                        </td>
                    </tr>
                </table>
            </xsl:when>
            <xsl:otherwise>
            </xsl:otherwise>
        </xsl:choose>




    </xsl:template>

</xsl:stylesheet>
