﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:include href="TaskFilterVersion.xslt" />
    <xsl:include href="Item.xslt"/>
    <xsl:template match="/">
        <xsl:variable name="TemplatePathURL" select ="Goal/TemplateURL"></xsl:variable>
        <xsl:variable name="GoalID" select="normalize-space(Goal/ID)"></xsl:variable>
        <xsl:variable name="DisplayCompleted" select="normalize-space(Goal/UserSettings/Completed)"></xsl:variable>
        <xsl:variable name="DisplayFuture" select="normalize-space(Goal/UserSettings/Future)"></xsl:variable>
        <xsl:variable name="DisplayCurrent" select="normalize-space(Goal/UserSettings/Current)"></xsl:variable>
        <xsl:variable name="DisplayMyItems" select="normalize-space(Goal/UserSettings/MyItems)"></xsl:variable>
        <xsl:variable name="DisplayOthersItems" select="normalize-space(Goal/UserSettings/Others)"></xsl:variable>
        <xsl:variable name="DisplayShareIt" select="normalize-space(Goal/UserSettings/ShareIt)"></xsl:variable>
        <xsl:variable name="OrderBy" select="Goal/OrderBy"/>
        <xsl:variable name="HostName" select="Goal/HostName"/>
        <xsl:variable name ="PastDueCount" select ="Goal/PastDueItems/PastDueItem/ItemCount"></xsl:variable>
        <xsl:variable name ="CompleteCount" select ="Goal/CompletedItems/CompletedItem/ItemCount"></xsl:variable>
        <xsl:variable name ="FutureCount" select ="Goal/FutureItems/FutureItem/ItemCount"></xsl:variable>
        <xsl:variable name ="GoalPermissionID" select ="normalize-space(Goal/PermissionID)"></xsl:variable>

        <div id="divGoalDetailBody" style="width:100%">
            <xsl:if test ="$OrderBy = 3 or $OrderBy = 4 or $OrderBy = 5">
                <div id="div_GoalOutlineTree_Filter" style="margin-bottom:15px">
                    <xsl:call-template name="TaskFilter">
                        <xsl:with-param name="Current" select="$DisplayCurrent"></xsl:with-param>
                        <xsl:with-param name="Completed" select="$DisplayCompleted"></xsl:with-param>
                        <xsl:with-param name="Future" select="$DisplayFuture"></xsl:with-param>
                        <xsl:with-param name="MyItems" select="$DisplayMyItems"></xsl:with-param>
                        <xsl:with-param name="Others" select="$DisplayOthersItems"></xsl:with-param>
                        <xsl:with-param name="GoalItemID" select="$GoalID"></xsl:with-param>
                    </xsl:call-template>
                </div>
            </xsl:if>

            <div id="div_GoalOutlineTree" style="width:100%">
                <input type="hidden" id="hiddenGoalID" value="{$GoalID}"></input>
                <table cellspacing="2" cellpadding="2" width="100%">
                    <tr style="background-color:#C6C4C4;">
                        <xsl:if test ="$OrderBy = 3">
                            <td class="labelFormFields" style="background-color:#376092;text-align:center;" width="25%"
                                        id="td_1_Display_Menu" onClick="displaySelectedAction('1');">
                                <input id="rdbViewGoalTopic" type="radio" checked="true" name="orderByNewGoal"
                                       style="display:none;">
                                    <a style="font-family: Calibri, Verdana, Arial;
	                                        font-size: 12pt;cursor:pointer;color:#FFFFFF;"
                                    onClick="goal_LoadGoalVersion('divGoalDetailBody', '{$GoalID}', '1.1', '3','1');">View By Topic</a>
                                </input>
                            </td>
                            <td class="labelFormFields" style="text-align:center;" width="25%" id="td_2_Display_Menu"
                                            onClick="displaySelectedAction('2');">
                                <input id="rdbViewGoalDay" type="radio" name="orderByNewGoal"
                                       style="display:none;">
                                    <a style="font-family: Calibri, Verdana, Arial;
	                                        font-size: 12pt;cursor:pointer;color:#FFFFFF;"
                                    onClick="goal_LoadGoalVersion('divGoalDetailBody', '{$GoalID}', '1.1', '4','1');">View By Day</a>
                                </input>
                            </td>
                            <td class="labelFormFields" style="text-align:center;" width="25%" id="td_3_Display_Menu"
                                             onClick="displaySelectedAction('3');">
                                <input id="rdbViewGoalMonth" type="radio" name="orderByNewGoal"
                                       style="display:none;">
                                    <a style="font-family: Calibri, Verdana, Arial;
	                                        font-size: 12pt;cursor:pointer;color:#FFFFFF;"
                                    onClick="goal_LoadGoalVersion('divGoalDetailBody', '{$GoalID}', '1.1', '5','1');">View By Month</a>
                                </input>
                            </td>
                        </xsl:if>
                        <xsl:if test ="$OrderBy = 4">
                            <td class="labelFormFields" style="text-align:center;" width="25%"
                                       id="td_1_Display_Menu" onClick="displaySelectedAction('1');">
                                <input id="rdbViewGoalTopic" type="radio" checked="true" name="orderByNewGoal"
                                       style="display:none;">
                                    <a style="font-family: Calibri, Verdana, Arial;
	                                        font-size: 12pt;cursor:pointer;color:#FFFFFF;"
                                    onClick="goal_LoadGoalVersion('divGoalDetailBody', '{$GoalID}', '1.1', '3','1');">View By Topic</a>
                                </input>
                            </td>
                            <td class="labelFormFields" style="background-color:#376092;text-align:center;" width="25%" id="td_2_Display_Menu"
                                            onClick="displaySelectedAction('2');">
                                <input id="rdbViewGoalDay" type="radio" name="orderByNewGoal"
                                       style="display:none;">
                                    <a style="font-family: Calibri, Verdana, Arial;
	                                        font-size: 12pt;cursor:pointer;color:#FFFFFF;"
                                    onClick="goal_LoadGoalVersion('divGoalDetailBody', '{$GoalID}', '1.1', '4','1');">View By Day</a>
                                </input>
                            </td>
                            <td class="labelFormFields" style="text-align:center;" width="25%" id="td_3_Display_Menu"
                                             onClick="displaySelectedAction('3');">
                                <input id="rdbViewGoalMonth" type="radio" name="orderByNewGoal"
                                       style="display:none;">
                                    <a style="font-family: Calibri, Verdana, Arial;
	                                        font-size: 12pt;cursor:pointer;color:#FFFFFF;"
                                    onClick="goal_LoadGoalVersion('divGoalDetailBody', '{$GoalID}', '1.1', '5','1');">View By Month</a>
                                </input>
                            </td>                          
                        </xsl:if>
                        <xsl:if test ="$OrderBy = 5">                           
                            <td class="labelFormFields" style="text-align:center;" width="25%"
                                       id="td_1_Display_Menu" onClick="displaySelectedAction('1');">
                                <input id="rdbViewGoalTopic" type="radio" checked="true" name="orderByNewGoal"
                                       style="display:none;">
                                    <a style="font-family: Calibri, Verdana, Arial;
	                                        font-size: 12pt;cursor:pointer;color:#FFFFFF;"
                                    onClick="goal_LoadGoalVersion('divGoalDetailBody', '{$GoalID}', '1.1', '3','1');">View By Topic</a>
                                </input>
                            </td>
                            <td class="labelFormFields" style="text-align:center;" width="25%" id="td_2_Display_Menu"
                                            onClick="displaySelectedAction('2');">
                                <input id="rdbViewGoalDay" type="radio" name="orderByNewGoal"
                                       style="display:none;">
                                    <a style="font-family: Calibri, Verdana, Arial;
	                                        font-size: 12pt;cursor:pointer;color:#FFFFFF;"
                                    onClick="goal_LoadGoalVersion('divGoalDetailBody', '{$GoalID}', '1.1', '4','1');">View By Day</a>
                                </input>
                            </td>
                            <td class="labelFormFields" style="background-color:#376092;text-align:center;" width="25%" id="td_3_Display_Menu"
                                             onClick="displaySelectedAction('3');">
                                <input id="rdbViewGoalMonth" type="radio" name="orderByNewGoal"
                                       style="display:none;">
                                    <a style="font-family: Calibri, Verdana, Arial;
	                                        font-size: 12pt;cursor:pointer;color:#FFFFFF;"
                                    onClick="goal_LoadGoalVersion('divGoalDetailBody', '{$GoalID}', '1.1', '5','1');">View By Month</a>
                                </input>
                            </td>
                        </xsl:if>                       
                    </tr>
                </table>
            </div>

            <div id="divGoalTree_Items" style="margin-top:10px;">
                <xsl:if test ="$OrderBy = 5">
                    <xsl:value-of select ="normalize-space(Goal/MonthHTML)" disable-output-escaping ="yes"/>
                </xsl:if>
                <xsl:if test ="$OrderBy = 4">
                    <xsl:if test ="$PastDueCount &gt; 0">
                        <div id="div_GoalTree_PastDue">
                            <div id="div_GoalTree_PastDue_Header" class="seperatorLine link"
                                 onclick="return goal_getGoalDetailForSelectedOrder('div_GoalTree_PastDue_Content', 'PastDue', '4', '{$GoalID}');">
                                <table cellspacing="0" cellpadding="0" width="100%">
                                    <tr>
                                        <td>
                                            <span class="labelBoldItalic" style="color:red">
                                                Past Due&#xa0;(<span id="div_GoalTree_PastDue_Header_Count">
                                                    <xsl:value-of select ="$PastDueCount"/>
                                                </span>)
                                            </span>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="div_GoalTree_PastDue_Content" style="display: none;" class="seperatorLine">
                            </div>
                        </div>
                    </xsl:if>
                    <xsl:if test ="$CompleteCount &gt; 0">
                        <div id="div_GoalTree_Completed">
                            <div id="div_GoalTree_Completed_Header" class="seperatorLine link"
                                 onclick="return goal_getGoalDetailForSelectedOrder('div_GoalTree_Completed_Content', 'Completed', '4', '{$GoalID}');">
                                <table cellspacing="0" cellpadding="0" width="100%">
                                    <tr>
                                        <td>
                                            <span class="labelBoldItalic">
                                                Completed&#xa0;(<span id="div_GoalTree_Completed_Header_Count">
                                                    <xsl:value-of select ="$CompleteCount"/>
                                                </span>)
                                            </span>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="div_GoalTree_Completed_Content" style="display: none;" class="seperatorLine">
                            </div>
                        </div>
                    </xsl:if>
                </xsl:if>
                <xsl:if test ="$OrderBy = 3">
                    <xsl:for-each select ="Goal/SummaryItems/SummaryItem">
                        <xsl:variable name="KeyParameter" select ="normalize-space(KeyParameter)"/>
                        <xsl:if test="normalize-space(TypeID) = 9 or normalize-space(TypeID) = 28 or  normalize-space(TypeID) = 30">                          
                            <xsl:for-each select="../../DetailItems/DetailItem[normalize-space(ItemID)=$KeyParameter]">
                                <xsl:variable name ="DisplayStyle">
                                    <xsl:choose>
                                        <xsl:when test ="($DisplayCompleted = 1 and normalize-space(StatusID) = 4 and $DisplayMyItems = 1 and normalize-space(MineOrOther) = 'Me') 
                                                                    or ($DisplayCompleted = 1 and normalize-space(StatusID) = 4 and $DisplayOthersItems = 1 and normalize-space(MineOrOther) != 'Me')
                                                                    or ($DisplayFuture = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&gt; 7 and $DisplayMyItems = 1 and normalize-space(MineOrOther) = 'Me')
                                                                    or ($DisplayFuture = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&gt; 7 and $DisplayOthersItems = 1 and normalize-space(MineOrOther) != 'Me')
                                                                    or ($DisplayCurrent = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&lt;= 7 and $DisplayMyItems = 1 and normalize-space(MineOrOther) = 'Me')
                                                                    or ($DisplayCurrent = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&lt;= 7 and $DisplayOthersItems = 1 and normalize-space(MineOrOther) != 'Me')
                                                                    or normalize-space(TypeID) = 17 or normalize-space(TypeID) = 24 or normalize-space(TypeID) = 28 or normalize-space(TypeID) = 30">
                                            display:block
                                        </xsl:when>
                                        <xsl:otherwise>
                                            display:none
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>
                                <xsl:call-template name="Item">
                                    <xsl:with-param name="ItemDivPrefix">
                                        <xsl:text>div</xsl:text>
                                    </xsl:with-param>
                                    <xsl:with-param name="ItemID" select="ItemID"></xsl:with-param>
                                    <xsl:with-param name="OwnerPortalItemID" select="OwnerPortalItemID"></xsl:with-param>
                                    <xsl:with-param name="ItemName" select="Item"></xsl:with-param>
                                    <xsl:with-param name="TemplatePathURL" select="$TemplatePathURL"></xsl:with-param>
                                    <xsl:with-param name="ItemSubID" select="ItemSubID"></xsl:with-param>
                                    <xsl:with-param name="ItemSubTitle" select="ItemSubTitle"></xsl:with-param>
                                    <xsl:with-param name="StatusID" select="StatusID"></xsl:with-param>
                                    <xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
                                    <xsl:with-param name="OrderBy" select="$OrderBy"></xsl:with-param>
                                    <xsl:with-param name="PermissionID" select="PermissionID"></xsl:with-param>
                                    <xsl:with-param name="TotalDays" select="TotalDays"></xsl:with-param>
                                    <xsl:with-param name="KeyParameter" select="KeyParameter"></xsl:with-param>
                                    <xsl:with-param name="ItemType" select="ItemType"></xsl:with-param>
                                    <xsl:with-param name="RefItemType" select="RefItemTypeID"></xsl:with-param>
                                    <xsl:with-param name="RefItemID" select="RefItemID"></xsl:with-param>
                                    <xsl:with-param name="GoalID" select="$GoalID"></xsl:with-param>
                                    <xsl:with-param name="DisplayStyle" select="$DisplayStyle"></xsl:with-param>
                                    <xsl:with-param name="MineOrOther" select="normalize-space(MineOrOther)"></xsl:with-param>
                                    <xsl:with-param name="ImageAttach" select="normalize-space(ImageAttach)"></xsl:with-param>
                                    <xsl:with-param name="ItemSubTitleContent" select="normalize-space(ItemSubTitleContent)"></xsl:with-param>
                                    <xsl:with-param name="TemplateSourceID" select="TemplateSourceID"></xsl:with-param>
                                    <xsl:with-param name="FirstName" select="FirstName"></xsl:with-param>
                                  <xsl:with-param name="Subject" select="Subject"></xsl:with-param>
                                  <xsl:with-param name="Body" select="Body"></xsl:with-param>
                                </xsl:call-template>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="normalize-space(TypeID) = 17">
                            <div id="div_{KeyParameter}" name="collapsed" type="Summary" itemID="{KeyParameter}">
                                <itemExpansionStatus id="div_{KeyParameter}_expansionStatus" status="collapsed"></itemExpansionStatus>
                                <xsl:variable name ="ContentClass">
                                    <xsl:if test="normalize-space(following::TypeID) = 9 and 
                                        count(../../DetailItems/DetailItem[normalize-space(KeyParameter)=$KeyParameter]) &gt; 0">
                                        <xsl:text>seperatorLine</xsl:text>
                                    </xsl:if>
                                </xsl:variable>
                                <input type="hidden" id="div_{KeyParameter}_hiddenItemTypeID" value="{normalize-space(TypeID)}"></input>
                                <div id="div_{KeyParameter}_Header" class="seperatorLine link" name="collapsed" style="padding-top:10px; padding-right:10px; padding-left:10px;padding-bottom:0px;">
                                    <itemExpansionStatus id="div_{KeyParameter}_Header_expansionStatus" status="collapsed"></itemExpansionStatus>
                                    <table cellspacing="0" cellpadding="0" width="100%">
                                        <tr>
                                            <td width="75%">
                                                <xsl:if test ="$OrderBy = 3">
                                                    <span class="labelBoldItalic"
                                                          onclick="itemSummary_Expand(event, '{KeyParameter}');">
                                                        <!--return goal_getGoalForSelectedOrder('div_{KeyParameter}_Content','{KeyParameter}', '{$OrderBy}', '{$GoalID}');-->
                                                        <span id="div_{KeyParameter}_SpanTitle">
                                                            <xsl:value-of select ="Title"/>
                                                        </span>&#xa0;
                                                        &#xa0;(<span id="div_{KeyParameter}_Header_Count">
                                                            <xsl:value-of select ="ItemCount"/>
                                                        </span>)
                                                    </span>
                                                    &#xa0;&#xa0;
                                                    <div id="div_{KeyParameter}_HeaderControls" style="padding-top:10px; display:none;margin-bottom:5px;">
                                                        <xsl:choose>
                                                            <xsl:when test="$GoalPermissionID = 3 or $GoalPermissionID = 4">
                                                                <span class="link" onclick="actionUpdateMode_ForVersion('{KeyParameter}', 'div_{KeyParameter}_Header_operations', '{$GoalID}', 'div_{KeyParameter}', 'GoalDetail', '1.1');">
                                                                    <img align="absmiddle" title="Mark Complete" class="lsSprite lsIcon16 itemMenuUpdate" src="{$TemplatePathURL}Web/Images/transparent.gif"></img>&#xa0;Edit
                                                                </span>
                                                                &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;
                                                                <span class="link" onclick="return DeleteActionMode_ForVersion('{KeyParameter}',  '{$GoalID}', 'div_{KeyParameter}', '1.1');">
                                                                    <img align="absmiddle" title="Mark Complete" class="lsSprite lsIcon16 itemMenuDelete" src="{$TemplatePathURL}Web/Images/transparent.gif"></img>&#xa0;Delete
                                                                </span>
                                                            </xsl:when>
                                                            <xsl:otherwise>
                                                                <span class="link">
                                                                    <img align="absmiddle" title="Mark Complete" class="lsSprite lsIcon16 itemMenuUpdate" src="{$TemplatePathURL}Web/Images/transparent.gif"></img>&#xa0;Edit
                                                                </span>
                                                                &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;
                                                                <span class="link">
                                                                    <img align="absmiddle" title="Mark Complete" class="lsSprite lsIcon16 itemMenuDelete" src="{$TemplatePathURL}Web/Images/transparent.gif"></img>&#xa0;Delete
                                                                </span>
                                                            </xsl:otherwise>
                                                        </xsl:choose>
                                                        <!--<xsl:if test ="PermissionID = 4">-->
                                                        <!--</xsl:if>-->
                                                    </div>
                                                    <!--<div id="div_{KeyParameter}_HeaderControls_AddNewItem" style="display:none;margin:15px;">
                                                                      
                                                                 </div>-->
                                                </xsl:if>
                                            </td>
                                            <td width="25%">
                                                <xsl:if test ="$OrderBy = 3">
                                                    <div class="labelBoldItalic" style="text-align:right;">
                                                        <xsl:value-of select ="SubTitle"/>
                                                    </div>
                                                </xsl:if>
                                            </td>
                                        </tr>
                                    </table>
                                    <div id="div_{KeyParameter}_Header_operations" style="margin:10px;display:none;">
                                    </div>
                                </div>
                                <div id="div_{KeyParameter}_Content" style="display:block;">
                                    <xsl:for-each select="../../DetailItems/DetailItem[normalize-space(KeyParameter)=$KeyParameter]">
                                        <xsl:variable name ="DisplayStyle">
                                            <xsl:choose>
                                                <xsl:when test ="($DisplayCompleted = 1 and normalize-space(StatusID) = 4 and $DisplayMyItems = 1 and normalize-space(MineOrOther) = 'Me') 
                                                                    or ($DisplayCompleted = 1 and normalize-space(StatusID) = 4 and $DisplayOthersItems = 1 and normalize-space(MineOrOther) != 'Me')
                                                                    or ($DisplayFuture = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&gt; 7 and $DisplayMyItems = 1 and normalize-space(MineOrOther) = 'Me')
                                                                    or ($DisplayFuture = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&gt; 7 and $DisplayOthersItems = 1 and normalize-space(MineOrOther) != 'Me')
                                                                    or ($DisplayCurrent = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&lt;= 7 and $DisplayMyItems = 1 and normalize-space(MineOrOther) = 'Me')
                                                                    or ($DisplayCurrent = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&lt;= 7 and $DisplayOthersItems = 1 and normalize-space(MineOrOther) != 'Me')
                                                                    or normalize-space(TypeID) = 17 or normalize-space(TypeID) = 24 or normalize-space(TypeID) = 28 or normalize-space(TypeID) = 30">
                                                    display:block
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    display:none
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:variable>
                                        <xsl:call-template name="Item">
                                            <xsl:with-param name="ItemDivPrefix">
                                                <xsl:text>div</xsl:text>
                                            </xsl:with-param>
                                            <xsl:with-param name="ItemID" select="ItemID"></xsl:with-param>
                                            <xsl:with-param name="OwnerPortalItemID" select="OwnerPortalItemID"></xsl:with-param>
                                            <xsl:with-param name="ItemName" select="Item"></xsl:with-param>
                                            <xsl:with-param name="TemplatePathURL" select="$TemplatePathURL"></xsl:with-param>
                                            <xsl:with-param name="ItemSubID" select="ItemSubID"></xsl:with-param>
                                            <xsl:with-param name="ItemSubTitle" select="ItemSubTitle"></xsl:with-param>
                                            <xsl:with-param name="StatusID" select="StatusID"></xsl:with-param>
                                            <xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
                                            <xsl:with-param name="OrderBy" select="$OrderBy"></xsl:with-param>
                                            <xsl:with-param name="PermissionID" select="PermissionID"></xsl:with-param>
                                            <xsl:with-param name="TotalDays" select="TotalDays"></xsl:with-param>
                                            <xsl:with-param name="KeyParameter" select="KeyParameter"></xsl:with-param>
                                            <xsl:with-param name="ItemType" select="ItemType"></xsl:with-param>
                                            <xsl:with-param name="RefItemType" select="RefItemTypeID"></xsl:with-param>
                                            <xsl:with-param name="RefItemID" select="RefItemID"></xsl:with-param>
                                            <xsl:with-param name="GoalID" select="$GoalID"></xsl:with-param>
                                            <xsl:with-param name="DisplayStyle" select="$DisplayStyle"></xsl:with-param>
                                            <xsl:with-param name="MineOrOther" select="normalize-space(MineOrOther)"></xsl:with-param>
                                            <xsl:with-param name="ImageAttach" select="normalize-space(ImageAttach)"></xsl:with-param>
                                            <xsl:with-param name="ItemSubTitleContent" select="normalize-space(ItemSubTitleContent)"></xsl:with-param>
                                            <xsl:with-param name="TemplateSourceID" select="TemplateSourceID"></xsl:with-param>
                                            <xsl:with-param name="FirstName" select="FirstName"></xsl:with-param>
                                          <xsl:with-param name="Subject" select="Subject"></xsl:with-param>
                                          <xsl:with-param name="Body" select="Body"></xsl:with-param>
                                        </xsl:call-template>
                                    </xsl:for-each>
                                </div>
                                <div id="div_{KeyParameter}_Footer" style="margin-left:35px;display:none;" name="collapsed" ItemID="{KeyParameter}">
                                    <itemExpansionStatus id="div_{KeyParameter}_Footer_expansionStatus" status="collapsed"></itemExpansionStatus>
                                    <div class="link" style="padding-bottom:10px; padding-top:10px;display:block;" id="div_Topic_{KeyParameter}_AddAction">
                                        <xsl:if test="$GoalPermissionID = 4">
                                            <input class="textAreaGoal" value="Add new item here..."
                                                   onclick="ItemNewMode_ForVersion('{KeyParameter}','{$GoalID}', 'div_{KeyParameter}_Footer_operations','1.1','{Title}');"></input>
                                        </xsl:if>
                                    </div>
                                    <div id="div_{KeyParameter}_Footer_operations" style="margin-top:10px;margin-bottom:10px;display:none;">
                                    </div>
                                </div>
                            </div>
                        </xsl:if>
                    </xsl:for-each>
                </xsl:if>
                <xsl:if test ="$OrderBy = 4">
                    <xsl:for-each select ="Goal/SummaryItems/SummaryItem">
                        <div id="div_{KeyParameter}">
                            <div id="div_{KeyParameter}_Header" class="seperatorLine link">
                                <table cellspacing="0" cellpadding="0" width="100%">
                                    <tr>
                                        <td width="75%">
                                            <span class="labelBoldItalic"
                                                  onclick="return goal_getGoalForSelectedOrder('div_{KeyParameter}_Content','{KeyParameter}', '{$OrderBy}', '{$GoalID}');">
                                                <xsl:value-of select ="Title"/>&#xa0;(<span id="div_{KeyParameter}_Header_Count">
                                                    <xsl:value-of select ="ItemCount"/>
                                                </span>)
                                            </span>
                                        </td>
                                        <td width="25%">
                                            <div class="labelBoldItalic" style="text-align:right">
                                                <xsl:value-of select ="SubTitle"/>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <xsl:variable name="KeyParameter" select ="normalize-space(KeyParameter)"/>
                            <div id="div_{KeyParameter}_Content" style="display:block;">
                                <xsl:for-each select="../../DetailItems/DetailItem[normalize-space(KeyParameter)=$KeyParameter]">
                                    <xsl:variable name ="DisplayStyle">
                                        <xsl:choose>
                                            <xsl:when test ="($DisplayCompleted = 1 and normalize-space(StatusID) = 4 and $DisplayMyItems = 1 and normalize-space(MineOrOther) = 'Me') 
                                                                    or ($DisplayCompleted = 1 and normalize-space(StatusID) = 4 and $DisplayOthersItems = 1 and normalize-space(MineOrOther) != 'Me')
                                                                    or ($DisplayFuture = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&gt; 7 and $DisplayMyItems = 1 and normalize-space(MineOrOther) = 'Me')
                                                                    or ($DisplayFuture = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&gt; 7 and $DisplayOthersItems = 1 and normalize-space(MineOrOther) != 'Me')
                                                                    or ($DisplayCurrent = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&lt;= 7 and $DisplayMyItems = 1 and normalize-space(MineOrOther) = 'Me')
                                                                    or ($DisplayCurrent = 1 and normalize-space(StatusID) != 4 and normalize-space(TotalDays)&lt;= 7 and $DisplayOthersItems = 1 and normalize-space(MineOrOther) != 'Me')">
                                                display:block
                                            </xsl:when>
                                            <xsl:otherwise>
                                                display:none
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <xsl:call-template name="Item">
                                        <xsl:with-param name="ItemDivPrefix">
                                            <xsl:text>div</xsl:text>
                                        </xsl:with-param>
                                        <xsl:with-param name="ItemID" select="ItemID"></xsl:with-param>
                                        <xsl:with-param name="OwnerPortalItemID" select="OwnerPortalItemID"></xsl:with-param>
                                        <xsl:with-param name="ItemName" select="Item"></xsl:with-param>
                                        <xsl:with-param name="TemplatePathURL" select="$TemplatePathURL"></xsl:with-param>
                                        <xsl:with-param name="ItemSubID" select="ItemSubID"></xsl:with-param>
                                        <xsl:with-param name="ItemSubTitle" select="ItemSubTitle"></xsl:with-param>
                                        <xsl:with-param name="StatusID" select="StatusID"></xsl:with-param>
                                        <xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
                                        <xsl:with-param name="OrderBy" select="$OrderBy"></xsl:with-param>
                                        <xsl:with-param name="PermissionID" select="PermissionID"></xsl:with-param>
                                        <xsl:with-param name="TotalDays" select="TotalDays"></xsl:with-param>
                                        <xsl:with-param name="KeyParameter" select="KeyParameter"></xsl:with-param>
                                        <xsl:with-param name="ItemType" select="ItemType"></xsl:with-param>
                                        <xsl:with-param name="RefItemType" select="RefItemTypeID"></xsl:with-param>
                                        <xsl:with-param name="RefItemID" select="RefItemID"></xsl:with-param>
                                        <xsl:with-param name="GoalID" select="$GoalID"></xsl:with-param>
                                        <xsl:with-param name="DisplayStyle" select="$DisplayStyle"></xsl:with-param>
                                        <xsl:with-param name="MineOrOther" select="normalize-space(MineOrOther)"></xsl:with-param>
                                        <xsl:with-param name="TemplateSourceID" select="TemplateSourceID"></xsl:with-param>
                                        <xsl:with-param name="FirstName" select="FirstName"></xsl:with-param>
                                      <xsl:with-param name="Subject" select="Subject"></xsl:with-param>
                                      <xsl:with-param name="Body" select="Body"></xsl:with-param>
                                    </xsl:call-template>
                                </xsl:for-each>
                            </div>
                        </div>
                    </xsl:for-each>
                </xsl:if>
                <xsl:if test ="$OrderBy = 4">
                    <xsl:if test ="$FutureCount &gt; 0">
                        <div id="div_GoalTree_Future">
                            <div id="div_GoalTree_Future_Header" class="seperatorLine link"
                                 onclick="return goal_getGoalDetailForSelectedOrder('div_GoalTree_Future_Content', 'Future', '4', '{$GoalID}');">
                                <table cellspacing="0" cellpadding="0" width="100%">
                                    <tr>
                                        <td>
                                            <span class="labelBoldItalic">
                                                Future&#xa0;(<span id="div_GoalTree_Future_Header_Count">
                                                    <xsl:value-of select ="$FutureCount"/>
                                                </span>)
                                            </span>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="div_GoalTree_Future_Content" style="display: none;" class="seperatorLine">
                            </div>
                        </div>
                    </xsl:if>
                </xsl:if>
            </div>

            <xsl:if test ="$OrderBy != 5">
                <xsl:if test="count(Goal/AddNewItem) &gt; 0">
                    <div id="divParentAddNewItem" style="margin-bottom:10px;margin-top:10px;">
                        <div id="divAddNewItem">
                            <div id="divTxtAddAction" style="display: block;">
                                <input id="txtAddAction" class="textAreaGoal" value="Add new item here..."
                                       onclick="ItemNewMode_ForVersion('0','{$GoalID}', 'divGoalTask','1.1','None');"/>
                            </div>
                            <div id="divGoalTask" style="display: none">
                                <xsl:value-of select="Goal/AddNewItem/Html" disable-output-escaping ="yes"/>
                            </div>
                        </div>
                    </div>
                </xsl:if>
            </xsl:if>
        </div>
    </xsl:template>
</xsl:stylesheet>
