﻿<?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="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: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: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="$Authenticated = 'True'">
                    <xsl:choose>
                        <xsl:when test="($ItemType = 'None' and $ItemID = 0) and normalize-space($Debug) = 'False'">
                            <xsl:call-template name="MyPlan">
                                <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:call-template>
                            <xsl:call-template name="MyItems">
                                <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:call-template>
                            <!--<xsl:if test="$Version = '1.2'">
                                <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:if>
                            <xsl:call-template name="GetInspired">
                                <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:call-template>-->
                        </xsl:when>
                        <xsl:when test="$ItemType = 'Template' or $ItemType = 'LSPublication' or $ItemType = 'Community' or $ItemType = 'Discussion'">
                            <xsl:call-template name="MyPlan">
                                <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:call-template>
                            <xsl:call-template name="MyItems">
                                <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:call-template>
                        </xsl:when>
                      <xsl:when test="$ItemType = 'WorkOut'">
                        <xsl:call-template name="MyItems">
                          <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:call-template>
                      </xsl:when>
                        <xsl:when test="$ItemType = 'Portal'">
                            <xsl:if test="$PermissionID &gt; 0">
                                <xsl:call-template name ="ClientPortalLeftContent">
                                    <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="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:if>
                        </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: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:call-template name="LifeSpaceLeftBar" />
                    <xsl:call-template name="GetStartedMenu">
                        <xsl:with-param name="TemplateUrl" select="normalize-space($TemplateURL)"></xsl:with-param>
                        <xsl:with-param name="HostName" select="normalize-space($HostName)"></xsl:with-param>
                    </xsl:call-template>
                </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" 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_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>

        <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: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>


        <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:template>

</xsl:stylesheet>
