﻿<?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="LifeSpaceLeftBar.xslt"/>
    <xsl:import href="GetStartedMenu.xslt"/>
    <xsl:import href="Version_2_0/ActiveLifeSpacesLoader.xslt"/>
    <xsl:import href="Version_2_0/Community/LeftNavigation.xslt"/>
    <xsl:import href="AsynchronousContainerVersion12/AsynchronousClientPortalLeftContent.xslt"/>

    <xsl:output indent ="no"></xsl:output>

    <xsl:template match="/">
        <xsl:call-template name="InitializeNavBar">
            <xsl:with-param name="TemplateURL" 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="Version" select="normalize-space(AjaxRequest/Params/Version)"></xsl:with-param>
            <xsl:with-param name="ItemType" select="normalize-space(AjaxRequest/Params/ItemType)"></xsl:with-param>
            <xsl:with-param name="ParentType" select="normalize-space(AjaxRequest/Params/ParentType)"></xsl:with-param>
            <xsl:with-param name="ParentID" select="normalize-space(AjaxRequest/Params/ParentID)"></xsl:with-param>
            <xsl:with-param name="Authenticated" select="normalize-space(AjaxRequest/Params/Authenticated)"></xsl:with-param>
            <xsl:with-param name="Debug">
                <xsl:text>False</xsl:text>
            </xsl:with-param>
            <xsl:with-param name="HostName" select="normalize-space(AjaxRequest/HostName)"></xsl:with-param>
            <xsl:with-param name="PermissionID" select="normalize-space(AjaxRequest/Params/PermissionID)"/>
            <xsl:with-param name="ClientUserID" select="normalize-space(AjaxRequest/Params/ClientUserID)"/>
            <xsl:with-param name="DataFilter" select="normalize-space(AjaxRequest/Params/DataFilter)"/>
            <xsl:with-param name="MBrandItemID" select="normalize-space(AjaxRequest/Params/MBrandItemID)"/>
            <xsl:with-param name="SettingsXML" select="AjaxRequest/Settings/."></xsl:with-param>
            <xsl:with-param name="PopularPublications" select="AjaxRequest/CommunityPosts/Publications/PopularPublications/."></xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="InitializeNavBar">
        <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
        <xsl:param name="ItemID" select="'N/A'"></xsl:param>
        <xsl:param name="Version" select="'N/A'"></xsl:param>
        <xsl:param name="ItemType" select="'N/A'"></xsl:param>
        <xsl:param name="ParentType" select="'N/A'"></xsl:param>
        <xsl:param name="ParentID" select="'N/A'"></xsl:param>
        <xsl:param name="Authenticated" select="'N/A'"></xsl:param>
        <xsl:param name="Debug">
            <xsl:text>False</xsl:text>
        </xsl:param>
        <xsl:param name="HostName" select="'N/A'"></xsl:param>
        <xsl:param name="PortalModules" select="'N/A'"></xsl:param>
        <xsl:param name="PermissionID">
            <xsl:number value="-99"/>
        </xsl:param>
        <xsl:param name="ClientUserID" select="'N/A'"></xsl:param>
        <xsl:param name="LeftNavigationHTML" select="'N/A'"></xsl:param>
        <xsl:param name="DataFilter" select="'N/A'"></xsl:param>
        <xsl:param name="MBrandItemID" select="'N/A'"></xsl:param>
        <xsl:param name="AdditionalData" select="'N/A'"></xsl:param>
        <xsl:param name="PortalTypeID" select="'N/A'"></xsl:param>
        <xsl:param name="SettingsXML" select="'N/A'"></xsl:param>
        <xsl:param name="PopularPublications" select="'N/A'"></xsl:param>
        <xsl:param name="OwnerBrandID" select="'N/A'"></xsl:param>
        <xsl:param name="Target" select="'N/A'"></xsl:param>


        <xsl:variable name="FollowItItemID">
            <xsl:choose>
                <xsl:when test="$ItemType = 'LSPublication' or $ItemType = 'Community'">1</xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$ItemID"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <div id="divLeftNavigationBar">

            <xsl:choose>
                <xsl:when test="$ItemType = 'Community'">
                    <xsl:value-of select="$LeftNavigationHTML" disable-output-escaping="yes"/>
                </xsl:when>
                <xsl:when test="$Authenticated = 'True'">
                    <xsl:choose>
                        <xsl:when test="($ItemType = 'None' and $ItemID = 0) or $ItemType = 'Goal' or $ItemType = 'Template' 
                                    or $ItemType = 'Survey'
                                  or $ItemType = 'Action' or $ItemType = 'WorkOut' or $ItemType = 'NoteBook'
								  or ($ItemType = 'Portal' and ($DataFilter = 'Exclude' or $DataFilter = 'Limit'))">
                            <xsl:call-template name="ActiveLifeSpaces">
                                <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                                <xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
                                <xsl:with-param name="DataFilter" select="$DataFilter"></xsl:with-param>
                                <xsl:with-param name="MBrandItemID" select="$MBrandItemID"></xsl:with-param>
                                <xsl:with-param name="Version" select="$Version"></xsl:with-param>
                                <xsl:with-param name="Target" select="$Target"></xsl:with-param>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:when test="$ItemType = 'LSPublication' or $ItemType = 'Discussion'">
                            <xsl:call-template name="CommunityLeftNavigation">
                                <xsl:with-param name="LifeSpaceXML" select="AjaxRequest/LifeSpaces/."></xsl:with-param>
                                <xsl:with-param name="CommunitiesXML" select="AjaxRequest/Communities/."></xsl:with-param>
                                <xsl:with-param name="TemplateURL" select="AjaxRequest/TemplateURL"></xsl:with-param>
                                <xsl:with-param name="HostName" select="AjaxRequest/HostName"></xsl:with-param>
                                <xsl:with-param name="UserImageURL" select="AjaxRequest/User/UserData/FbPicURL"></xsl:with-param>
                                <xsl:with-param name="UserID" select="AjaxRequest/User/UserData/UserID"></xsl:with-param>
                                <xsl:with-param name="Authenticated" select="$Authenticated"></xsl:with-param>
                                <xsl:with-param name="ItemID" select="AjaxRequest/Params/ItemID"></xsl:with-param>
                                <xsl:with-param name="MasterPortalItemID" select="AjaxRequest/Settings/MasterPortalItemID"></xsl:with-param>
                                <xsl:with-param name="SettingsXML" select="$SettingsXML"></xsl:with-param>
                                <xsl:with-param name="PopularPublications" select="$PopularPublications"></xsl:with-param>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:when test="$ItemType = 'Portal' and (not($DataFilter) or $DataFilter = '' or $DataFilter = 'All')">
                            <xsl:choose>
                                <xsl:when test="$PermissionID &gt; 0">
                                    <xsl:call-template name ="ClientPortalLeftContent">
                                        <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                                        <xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
                                        <xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
                                        <xsl:with-param name="Version" select="$Version"></xsl:with-param>
                                        <xsl:with-param name="PortalModules" select="$PortalModules"></xsl:with-param>
                                        <xsl:with-param name="ClientUserID" select="$ClientUserID"></xsl:with-param>
                                        <xsl:with-param name="PermissionID" select="$PermissionID"></xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="($PermissionID &lt; 0 or $PermissionID &gt; 0) and normalize-space($Authenticated) = 'True' and $PortalTypeID = 2 and normalize-space($AdditionalData/PTPanel) = 'Patient'">
                                    <xsl:call-template name="ActiveLifeSpaces">
                                        <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                                        <xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
                                        <xsl:with-param name="DataFilter" select="$DataFilter"></xsl:with-param>
                                        <xsl:with-param name="MBrandItemID" select="$MBrandItemID"></xsl:with-param>
                                        <xsl:with-param name="Version" select="$Version"></xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="LifeSpaceMenu">
                                <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                                <xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
                                <xsl:with-param name="Version" select="$Version"></xsl:with-param>
                                <xsl:with-param name="ItemType" select="$ItemType"></xsl:with-param>
                            </xsl:call-template>
                            <xsl:call-template name="FollowedCommunities">
                                <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                                <xsl:with-param name="ItemID" select="$FollowItItemID"></xsl:with-param>
                                <xsl:with-param name="Version" select="$Version"></xsl:with-param>
                                <xsl:with-param name="ItemType" select="$ItemType"></xsl:with-param>
                                <xsl:with-param name="ParentType" select="$ParentType"></xsl:with-param>
                                <xsl:with-param name="ParentID" select="$ParentID"></xsl:with-param>
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:choose>
                        <xsl:when test="$ItemType = 'LSPublication' or $ItemType = 'Discussion'">
                            <xsl:call-template name="CommunityLeftNavigation">
                                <xsl:with-param name="LifeSpaceXML" select="AjaxRequest/LifeSpaces/."></xsl:with-param>
                                <xsl:with-param name="CommunitiesXML" select="AjaxRequest/Communities/."></xsl:with-param>
                                <xsl:with-param name="TemplateURL" select="AjaxRequest/TemplateURL"></xsl:with-param>
                                <xsl:with-param name="HostName" select="AjaxRequest/HostName"></xsl:with-param>
                                <xsl:with-param name="UserImageURL" select="AjaxRequest/User/UserData/FbPicURL"></xsl:with-param>
                                <xsl:with-param name="UserID" select="AjaxRequest/User/UserData/UserID"></xsl:with-param>
                                <xsl:with-param name="Authenticated" select="$Authenticated"></xsl:with-param>
                                <xsl:with-param name="ItemID" select="AjaxRequest/Params/ItemID"></xsl:with-param>
                                <xsl:with-param name="MasterPortalItemID" select="AjaxRequest/Settings/MasterPortalItemID"></xsl:with-param>
                                <xsl:with-param name="SettingsXML" select="$SettingsXML"></xsl:with-param>
                                <xsl:with-param name="PopularPublications" select="$PopularPublications"></xsl:with-param>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:when test="$ItemType != 'Goal' and $ItemType != 'Project'">

                        </xsl:when>
                        <xsl:otherwise>
                            <script language="javascript" type="text/javascript">
                                if(document.getElementById('divWorkingAreaLeftVerticalBar')!=null)
                                {document.getElementById('divWorkingAreaLeftVerticalBar').style.display = "none";}
                            </script>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:otherwise>
            </xsl:choose>
        </div>
    </xsl:template>

    <xsl:template name ="MyPlan">
        <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
        <xsl:param name="ItemID" select="'N/A'"></xsl:param>
        <xsl:param name="Version" select="'N/A'"></xsl:param>

        <div id="divLifeSpaceMyPlan" class="leftContentBox" style="margin-top:5px; margin-bottom:20px">
            <img id="imgWaiting" src="{normalize-space($TemplateURL)}Web/Images/pre-loader.gif"
                                style="vertical-align: middle;" runat="server"></img>
        </div>
        <script language="javascript" type="text/javascript">
            lifeSpaceFeatures_LoadMyPlan(
            "divLifeSpaceMyPlan",
            "<xsl:value-of select="$ItemID"/>",
            "<xsl:value-of select="normalize-space($Version)"/>");
        </script>

    </xsl:template>




    <xsl:template name ="MyItems">
        <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
        <xsl:param name="ItemID" select="'N/A'"></xsl:param>
        <xsl:param name="Version" select="'N/A'"></xsl:param>

        <div id="divLifeSpaceMyItems" class="leftContentBox">
            <img id="imgWaiting" src="{normalize-space($TemplateURL)}Web/Images/pre-loader.gif"
                                style="vertical-align: middle;" runat="server"></img>
        </div>
        <script language="javascript" type="text/javascript">
            lifeSpaceFeatures_LoadMyIems(
            "divLifeSpaceMyItems",
            "<xsl:value-of select="$ItemID"/>",
            "<xsl:value-of select="normalize-space($Version)"/>");
        </script>

    </xsl:template>

    <xsl:template name ="GetInspired">
        <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
        <xsl:param name="ItemID" select="'N/A'"></xsl:param>
        <xsl:param name="Version" select="'N/A'"></xsl:param>


        <div id="divLifeSpaceGetInspired" class="leftContentBox" style="margin-top:5px; margin-bottom:20px">
            <img id="imgWaiting" src="{normalize-space($TemplateURL)}Web/Images/pre-loader.gif"
                                style="vertical-align: middle;" runat="server"></img>
        </div>
        <script language="javascript" type="text/javascript">
            lifeSpaceFeatures_LoadGetInspired(
            "divLifeSpaceGetInspired",
            "<xsl:value-of select="$ItemID"/>",
            "NewDashBoard",
            1);
        </script>


    </xsl:template>

    <xsl:template name ="LifeSpaceMenu">
        <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
        <xsl:param name="ItemID" select="'N/A'"></xsl:param>
        <xsl:param name="Version" select="'N/A'"></xsl:param>
        <xsl:param name="ItemType" select="'N/A'"></xsl:param>

        <xsl:if test="$ItemType != 'None'">
            <div id="divLifeSpaceMenuContainer" class="leftContentBox" style="margin-top:5px; margin-bottom:20px">
                <img id="imgWaiting" src="{normalize-space($TemplateURL)}Web/Images/pre-loader.gif"
                                    style="vertical-align: middle;" runat="server"></img>


            </div>
            <script language="javascript" type="text/javascript">
                lifeSpaceFeatures_LoadLifeSpaceMenu(
                "<xsl:value-of select="$ItemID"/>",
                "divLifeSpaceMenuContainer",
                "<xsl:value-of select="normalize-space($Version)"/>");
            </script>
        </xsl:if>
    </xsl:template>

    <xsl:template name ="FollowedCommunities">
        <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
        <xsl:param name="ItemID" select="'N/A'"></xsl:param>
        <xsl:param name="Version" select="'N/A'"></xsl:param>
        <xsl:param name="ItemType" select="'N/A'"></xsl:param>
        <xsl:param name="ParentType" select="'N/A'"></xsl:param>
        <xsl:param name="ParentID" select="'N/A'"></xsl:param>

        <xsl:if test="$ItemType != 'None'">
            <div id="divFollowedCommunitiesContainer" class="leftContentBox" style="margin-top:5px; margin-bottom:20px">
                <img id="imgWaiting" src="{normalize-space($TemplateURL)}Web/Images/pre-loader.gif"
                                    style="vertical-align: middle;" runat="server"></img>

            </div>
            <xsl:choose>
                <xsl:when test ="$ItemType='Discussion'">
                    <xsl:choose>
                        <xsl:when test ="$ParentType='Goal'">
                            <script language="javascript" type="text/javascript">
                                lifeSpaceFeatures_LoadFollowedCommunities(
                                "<xsl:value-of select="$ParentID"/>",
                                "divFollowedCommunitiesContainer");
                            </script>
                        </xsl:when>
                        <xsl:when test ="$ParentType='Community'">
                            <script language="javascript" type="text/javascript">
                                lifeSpaceFeatures_LoadFollowedCommunities(
                                "-1",
                                "divFollowedCommunitiesContainer");
                            </script>
                        </xsl:when>
                    </xsl:choose>
                </xsl:when>
                <xsl:otherwise>
                    <script language="javascript" type="text/javascript">
                        lifeSpaceFeatures_LoadFollowedCommunities(
                        "<xsl:value-of select="$ItemID"/>",
                        "divFollowedCommunitiesContainer");
                    </script>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>
