﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:include href="GenericTemplates/DisplayTemplate.xslt" />

    <xsl:template match="/">
        <xsl:variable name="TemplatePathURL" select="normalize-space(CreateGoal/TemplateURL)"/>
        <xsl:variable name="itemID" select="normalize-space(CreateGoal/ItemID)"/>
        <xsl:variable name="RequestDivID" select="normalize-space(CreateGoal/RequestDivID)"/>
        <xsl:variable name="statusID" select="normalize-space(CreateGoal/Status/ItemStatus/ID)"/>
        <xsl:variable name="SourcePage" select="normalize-space(CreateGoal/SourcePage)"/>
        <xsl:variable name="OwnerID" select="normalize-space(CreateGoal/OwnerID)"/>
        <xsl:variable name="ProjectID" select="normalize-space(CreateGoal/ProjectID)"/>
        <xsl:variable name="CommunityAdmin" select="CreateGoal/UserRoles/Role/RoleName"></xsl:variable>


        <xsl:if test="$SourcePage = 'PlanPage'">
            <div id="div_CreateGoal" style="border: 2px solid rgb(56, 93, 138); padding:10px; margin-left:5px;">
                <div id="div_CreateGoal_close" align="right" style="display:none;">
                    <span onclick='CloseCreateGoal("div_CreateGoal");' class="link">[ X ]</span>
                </div>
                <div>
                    <xsl:if test ="$itemID != -99 and $itemID != 1">
                        <xsl:if test="$SourcePage !='PlanPage'">
                            <div id="div_recommendedTemplates">
                                <xsl:value-of select="CreateGoal/Templates/Html" disable-output-escaping="yes"/>
                            </div>
                        </xsl:if>
                        <div id="div_GoalDefaultForm" style="margin-top: 30px;">
                            <div style="margin-bottom: 10px;">
                                <span class="label" style="font-style: italic; font-weight: bold">
                                    Create your own goal manually by using this form:
                                </span>
                            </div>
                            <table class="tableMaster">
                                <tr>
                                    <td style="width: 20%;">
                                        <span class="labelFormFields">Goal</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{$itemID}_Title" type="text" value ="" class="text" maxlength="50"/>
                                        <span id ="span_item_{$itemID}_ErrorMessage" class="labelError" style="display:none;">*</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <span class="labelFormFields">Description</span>
                                    </td>
                                    <td>
                                        <textarea id="txt_Item_{$itemID}_Description" rows="2" class="textArea">
                                        </textarea>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <span class="labelFormFields">Measure Success</span>
                                    </td>
                                    <td>
                                        <select id ="opt_Item_{$itemID}_Success" name="lifespace" class="smallDropdownSuccess"
                                                onchange='setSuccessKeyDisplay("opt_Item_{$itemID}_Success", "div_{$itemID}_DisplayNumbers");'>
                                            <option value="Action" selected="selected">Completing Actions</option>
                                            <option value="Number">By Numbers and Metrics</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <div id="div_{$itemID}_DisplayNumbers" style="display:none;margin-left:-3px;">
                                            <table class="tableMaster">
                                                <tr>
                                                    <td style="width: 20%;">
                                                        <span class="labelFormFields">Target</span>
                                                    </td>
                                                    <td>
                                                        <span>
                                                            <select id ="opt_Item_{$itemID}_DisplayNumbers" name="lifespace" class="smallDropdown">
                                                                <option value="TotalAbove" selected="selected">Total Above</option>
                                                                <option value="PeriodAbove">Monthly Above</option>
                                                                <option value="PeriodBelow">Monthly Below</option>
                                                            </select>
                                                        </span>&#xa0;<span>
                                                            <select id ="opt_Item_{$itemID}_NumberFormat" style="width:50px"
                                                                    name="lifespace" class="smallDropdown"
                                                                    onChange='setSuccessFormat("opt_Item_{$itemID}_NumberFormat","txt_Item_{$itemID}_StartFormat");'>
                                                                <option value="$" selected="selected">$</option>
                                                                <option value="#">#</option>
                                                            </select>
                                                        </span>&#xa0;
                                                        <span>
                                                            <input id="txt_Item_{$itemID}_TargetAmount" type="text"
                                                                   value ="Amount" class="autoSuggest" style="width:75px;"
                                                                   onFocus='return SuccessKey_ClearAutoSuggestTextbox("txt_Item_{$itemID}_TargetAmount");'/>
                                                        </span>&#xa0;
                                                        <span>
                                                            <input id="txt_Item_{$itemID}_TargetWhat" type="text"
                                                                   value ="of what?" class="autoSuggest" style="width:75px;"
                                                                   onFocus='return SuccessKey_ClearAutoSuggestTextbox("txt_Item_{$itemID}_TargetWhat");'
                                                                   onBlur='SetTargetText("txt_Item_{$itemID}_TargetWhat", "txt_Item_{$itemID}_StartWhat");'/>
                                                        </span>&#xa0;
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 20%;">
                                                        <span class="labelFormFields">Starting With</span>
                                                    </td>
                                                    <td>
                                                        <span class="text" id="txt_Item_{$itemID}_StartFormat">
                                                            $
                                                        </span>&#xa0;
                                                        <span>
                                                            <input id="txt_Item_{$itemID}_StartAmount" type="text"
                                                                   value ="0.0" class="text" style="width:75px;"/>
                                                        </span>&#xa0;
                                                        <span class="text" id="txt_Item_{$itemID}_StartWhat">
                                                        </span>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 20%;">
                                                        <span class="labelFormFields">Track Amount</span>
                                                    </td>
                                                    <td>
                                                        <select id ="opt_Item_{$itemID}_TrackAmount"
                                                                onChange="goal_ChangeTargetAmountOption('opt_Item_{$itemID}_TrackAmount','opt_Item_{$itemID}_DisplayNumbers');"
                                                                name="lifespace" class="smallDropdown">
                                                            <option value="Daily" >Daily</option>
                                                            <option value="Weekly">Weekly</option>
                                                            <option value="Monthly" selected="selected">Monthly</option>
                                                            <option value="Quaterly">Quaterly</option>
                                                            <option value="Annually">Annually</option>
                                                        </select>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 20%;">
                                                        <span class="labelFormFields">Update Metrics</span>
                                                    </td>
                                                    <td>
                                                        <select id ="opt_Item_{$itemID}_UpdateMetrics" name="lifespace" class="smallDropdown">
                                                            <option value="Daily" >Daily</option>
                                                            <option value="Weekly" selected="selected">Weekly</option>
                                                            <option value="Monthly">Monthly</option>
                                                            <option value="Quaterly">Quaterly</option>
                                                            <option value="Annually">Annually</option>
                                                        </select>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <span class="labelFormFields">Image URL</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{normalize-space($itemID)}_ImageURL" type="text"
                                               class="text"/>
                                    </td>
                                </tr>
                                <xsl:if test ="$itemID  = -99 or $itemID = 1">
                                    <tr>
                                        <td>
                                            <span class="labelFormFields">LifeSpace</span>
                                        </td>
                                        <td>
                                            <select id ="opt_Item_{$itemID}_LifeSpace" name="lifespace" class="smallDropdown">
                                                <xsl:for-each select="CreateGoal/LifeSpaceList/LifeSpace/Item">
                                                    <option value="{ID/.}">
                                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                                    </option>
                                                </xsl:for-each>
                                            </select>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <tr>
                                    <td>
                                        <span class="labelFormFields">Start Date</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{$itemID}_StartDate" type="text" onblur="checkdate(this)"
                                               class="date" value =""/>
                                        <img src="{normalize-space($TemplatePathURL)}Web/Images/big_spacer.gif"></img>
                                        <img id="img_Item_{$itemID}_StartDate"
                                             src="{normalize-space($TemplatePathURL)}Web/Images/CalendarIcon.gif"
                                             onclick='dp("txt_Item_{$itemID}_StartDate", "img_Item_{$itemID}_StartDate");'></img>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <span class="labelFormFields">End Date</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{$itemID}_EndDate" type="text" onblur="checkdate(this)"
                                               runat="server" class="date" value =""/>
                                        <img src="{normalize-space($TemplatePathURL)}Web/Images/big_spacer.gif"></img>
                                        <img id="img_Item_{$itemID}_EndDate"
                                             src="{normalize-space($TemplatePathURL)}Web/Images/CalendarIcon.gif"
                                             onclick='dp("txt_Item_{$itemID}_EndDate", "img_Item_{$itemID}_EndDate");'></img>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <span class="labelFormFields"  style="display:none;">Status</span>
                                    </td>
                                    <td>
                                        <select id ="opt_Item_{$itemID}_Status"  style="display:none;" name="status" class="smallDropdown">
                                            <xsl:for-each select="CreateGoal/Status/ItamStatus">
                                                <xsl:if test ="$statusID=ID">
                                                    <option value="{ID/.}" selected="selected">
                                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                                    </option>
                                                </xsl:if>
                                                <xsl:if test ="$statusID!=ID">
                                                    <option value="{ID/.}">
                                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                                    </option>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>
                                        <input type="button" class="button"
                                                     onclick='return saveNewGoal(
                                                 "opt_Item_{$itemID}_UpdateMetrics",
                                                "opt_Item_{$itemID}_TrackAmount",
                                                "txt_Item_{$itemID}_StartAmount",
                                                "txt_Item_{$itemID}_TargetWhat",
                                                "txt_Item_{$itemID}_TargetAmount",
                                                "opt_Item_{$itemID}_NumberFormat",
                                                "opt_Item_{$itemID}_DisplayNumbers",
                                                "opt_Item_{$itemID}_Success",
                                                 "txt_Item_{$itemID}_Title",
                                                 "txt_Item_{$itemID}_Description",
                                                 "txt_Item_{$itemID}_StartDate",
                                                 "txt_Item_{$itemID}_EndDate",
                                                 "opt_Item_{$itemID}_Status",
                                                 "{$itemID}",
                                                 "span_item_{$itemID}_ErrorMessage", 
                                                 "div_Goals_{$itemID}",
                                                 "opt_Item_{$itemID}_LifeSpace",
                                                 "{$SourcePage}",
                                               "txt_Item_{normalize-space($itemID)}_ImageURL","{$OwnerID}","{$ProjectID}");'
                                                     value="Save"></input>
                                    </td>
                                    <td>
                                        <input type="button" class="button" onclick='return CloseCreateGoal("div_CreateGoal", "{$SourcePage}",{$itemID})' value="Cancel"></input>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </xsl:if>
                    <xsl:if test ="$itemID = -99 or  $itemID = 1">
                        <table width="100%">
                            <tr>
                                <td width="20%"></td>
                                <td width="60%">
                                    <div style="text-align: center;">
                                        <div style="margin-bottom: 20px;">
                                            <span class="labelHeader">
                                                Please select a lifespace for adding a new Goal
                                            </span>
                                        </div>
                                        <div style="text-align: center; width: 500px;">
                                            <table width="100%">
                                                <tr>
                                                    <td width="5%"></td>
                                                </tr>
                                                <tr>
                                                    <xsl:variable name="tdWidth">
                                                        <xsl:if test ="count(CreateGoal/LifeSpaceList/LifeSpace/Item) = 4">
                                                            <xsl:text>22%</xsl:text>
                                                        </xsl:if>
                                                        <xsl:if test ="count(CreateGoal/LifeSpaceList/LifeSpace/Item) = 5">
                                                            <xsl:text>16%</xsl:text>
                                                        </xsl:if>
                                                        <xsl:if test ="count(CreateGoal/LifeSpaceList/LifeSpace/Item) = 6">
                                                            <xsl:text>15%</xsl:text>
                                                        </xsl:if>
                                                    </xsl:variable>
                                                    <xsl:for-each select="CreateGoal/LifeSpaceList/LifeSpace/Item">
                                                        <td style="text-align:center;" width="{normalize-space($tdWidth)}">
                                                            <div align="center" class="link"
                                                                 onclick='return createNewGoal("{normalize-space(ID)}",
                                                                                "{$RequestDivID}","","");'>
                                                                <img src="{$TemplatePathURL}web/Images/{normalize-space(Name)}.jpg"
                                                                     alt="{normalize-space(Name)}"
                                                                     title="{normalize-space(Name)}"
                                                                     onload='setWidthAndHeightImage(this,"50");'
                                                                     onmouseover='return BorderOnMouseOver(true, this)'
                                                                     onmouseout='return BorderOnMouseOver(false, this)'/>
                                                                <div>
                                                                    <span>
                                                                        <xsl:value-of select='normalize-space(Name)'/>
                                                                    </span>
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </xsl:for-each>
                                                </tr>
                                                <tr>
                                                    <td width="5%"></td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                </td>
                                <td width="20%"></td>
                            </tr>
                        </table>
                    </xsl:if>
                </div>
            </div>
        </xsl:if>
        <xsl:if test="normalize-space(CreateGoal/SourcePage) != 'PlanPage'">
            <xsl:variable name ="divMargin">
                <xsl:choose>
                    <xsl:when test ="normalize-space(CreateGoal/SourcePage) = 'ClientPortalNewProject'">0px</xsl:when>
                    <xsl:otherwise>
                        <xsl:text>30px</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <div id="div_CreateGoal">
                <!--<div id="div_CreateGoal_close" align="right" style="display:none;">
                    <span onclick='CloseCreateGoal("div_CreateGoal");' class="link">[ X ]</span>
                </div>-->
                <div>
                    <xsl:if test ="$itemID != -99 and $itemID != 1">
                        <div id="div_recommendedTemplates">
                            <xsl:value-of select="CreateGoal/Templates/Html" disable-output-escaping="yes"/>
                        </div>
                        <div id="div_GoalDefaultForm" style="margin-top: {$divMargin};">
                            <div style="margin-bottom: 10px;">
                                <span class="label" style="font-style: italic; font-weight: bold">
                                    Create your own goal manually by using this form:
                                </span>
                            </div>
                            <table class="tableMaster">
                                <tr>
                                    <td style="width: 20%;">
                                        <span class="labelFormFields">Goal</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{$itemID}_Title" type="text" value ="" class="text" maxlength="50"/>
                                        <span id ="span_item_{$itemID}_ErrorMessage" class="labelError" style="display:none;">*</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <span class="labelFormFields">Description</span>
                                    </td>
                                    <td>
                                        <textarea id="txt_Item_{$itemID}_Description" rows="2" class="textArea">
                                        </textarea>
                                    </td>
                                </tr>
                                <xsl:if test ="$CommunityAdmin = 'Community Admin'">
                                    <tr>
                                        <td>
                                            <span class="labelFormFields">Measure Success</span>
                                        </td>
                                        <td>
                                            <select id ="opt_Item_{$itemID}_Success" name="lifespace" class="smallDropdownSuccess"
                                                    onchange='setSuccessKeyDisplay("opt_Item_{$itemID}_Success", "div_{$itemID}_DisplayNumbers");'>
                                                <option value="Action" selected="selected">Completing Actions</option>
                                                <option value="Number">By Numbers and Metrics</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <div id="div_{$itemID}_DisplayNumbers" style="display:none;margin-left:-3px;">
                                                <table class="tableMaster">
                                                    <tr>
                                                        <td style="width: 20%;">
                                                            <span class="labelFormFields">Target</span>
                                                        </td>
                                                        <td>
                                                            <span>
                                                                <select id ="opt_Item_{$itemID}_DisplayNumbers" name="lifespace" class="smallDropdown">
                                                                    <option value="TotalAbove" selected="selected">Total Above</option>
                                                                    <option value="PeriodAbove">Monthly Above</option>
                                                                    <option value="PeriodBelow">Monthly Below</option>
                                                                </select>
                                                            </span>&#xa0;<span>
                                                                <select id ="opt_Item_{$itemID}_NumberFormat" style="width:50px"
                                                                        name="lifespace" class="smallDropdown"
                                                                        onChange='setSuccessFormat("opt_Item_{$itemID}_NumberFormat","txt_Item_{$itemID}_StartFormat");'>
                                                                    <option value="$" selected="selected">$</option>
                                                                    <option value="#">#</option>
                                                                </select>
                                                            </span>&#xa0;
                                                            <span>
                                                                <input id="txt_Item_{$itemID}_TargetAmount" type="text"
                                                                       value ="Amount" class="autoSuggest" style="width:75px;"
                                                                       onFocus='return SuccessKey_ClearAutoSuggestTextbox("txt_Item_{$itemID}_TargetAmount");'/>
                                                            </span>&#xa0;
                                                            <span>
                                                                <input id="txt_Item_{$itemID}_TargetWhat" type="text"
                                                                       value ="of what?" class="autoSuggest" style="width:75px;"
                                                                       onFocus='return SuccessKey_ClearAutoSuggestTextbox("txt_Item_{$itemID}_TargetWhat");'
                                                                       onBlur='SetTargetText("txt_Item_{$itemID}_TargetWhat", "txt_Item_{$itemID}_StartWhat");'/>
                                                            </span>&#xa0;
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 20%;">
                                                            <span class="labelFormFields">Starting With</span>
                                                        </td>
                                                        <td>
                                                            <span class="text" id="txt_Item_{$itemID}_StartFormat">
                                                                $
                                                            </span>&#xa0;
                                                            <span>
                                                                <input id="txt_Item_{$itemID}_StartAmount" type="text"
                                                                       value ="0.0" class="text" style="width:75px;"/>
                                                            </span>&#xa0;
                                                            <span class="text" id="txt_Item_{$itemID}_StartWhat">
                                                            </span>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 20%;">
                                                            <span class="labelFormFields">Track Amount</span>
                                                        </td>
                                                        <td>
                                                            <select id ="opt_Item_{$itemID}_TrackAmount"
                                                                    onChange="goal_ChangeTargetAmountOption('opt_Item_{$itemID}_TrackAmount','opt_Item_{$itemID}_DisplayNumbers');"
                                                                    name="lifespace" class="smallDropdown">
                                                                <option value="Daily" >Daily</option>
                                                                <option value="Weekly">Weekly</option>
                                                                <option value="Monthly" selected="selected">Monthly</option>
                                                                <option value="Quaterly">Quaterly</option>
                                                                <option value="Annually">Annually</option>
                                                            </select>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 20%;">
                                                            <span class="labelFormFields">Update Metrics</span>
                                                        </td>
                                                        <td>
                                                            <select id ="opt_Item_{$itemID}_UpdateMetrics" name="lifespace" class="smallDropdown">
                                                                <option value="Daily" >Daily</option>
                                                                <option value="Weekly" selected="selected">Weekly</option>
                                                                <option value="Monthly">Monthly</option>
                                                                <option value="Quaterly">Quaterly</option>
                                                                <option value="Annually">Annually</option>
                                                            </select>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <tr>
                                    <td>
                                        <span class="labelFormFields">Image URL</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{normalize-space($itemID)}_ImageURL" type="text"
                                               class="text"/>
                                    </td>
                                </tr>
                                <xsl:if test ="$itemID  = -99 or $itemID = 1">
                                    <tr>
                                        <td>
                                            <span class="labelFormFields">LifeSpace</span>
                                        </td>
                                        <td>
                                            <select id ="opt_Item_{$itemID}_LifeSpace" name="lifespace" class="smallDropdown">
                                                <xsl:for-each select="CreateGoal/LifeSpaceList/LifeSpace/Item">
                                                    <option value="{ID/.}">
                                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                                    </option>
                                                </xsl:for-each>
                                            </select>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <tr>
                                    <td>
                                        <span class="labelFormFields">Start Date</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{$itemID}_StartDate" type="text" onblur="checkdate(this)"
                                               class="date" value =""/>
                                        <img src="{normalize-space($TemplatePathURL)}Web/Images/big_spacer.gif"></img>
                                        <img id="img_Item_{$itemID}_StartDate"
                                             src="{normalize-space($TemplatePathURL)}Web/Images/CalendarIcon.gif"
                                             onclick='dp("txt_Item_{$itemID}_StartDate", "img_Item_{$itemID}_StartDate");'></img>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <span class="labelFormFields">End Date</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{$itemID}_EndDate" type="text" onblur="checkdate(this)"
                                               runat="server" class="date" value =""/>
                                        <img src="{normalize-space($TemplatePathURL)}Web/Images/big_spacer.gif"></img>
                                        <img id="img_Item_{$itemID}_EndDate"
                                             src="{normalize-space($TemplatePathURL)}Web/Images/CalendarIcon.gif"
                                             onclick='dp("txt_Item_{$itemID}_EndDate", "img_Item_{$itemID}_EndDate");'></img>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <span class="labelFormFields"  style="display:none;">Status</span>
                                    </td>
                                    <td>
                                        <select id ="opt_Item_{$itemID}_Status"  style="display:none;" name="status" class="smallDropdown">
                                            <xsl:for-each select="CreateGoal/Status/ItamStatus">
                                                <xsl:if test ="$statusID=ID">
                                                    <option value="{ID/.}" selected="selected">
                                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                                    </option>
                                                </xsl:if>
                                                <xsl:if test ="$statusID!=ID">
                                                    <option value="{ID/.}">
                                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                                    </option>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <input type="button" class="button"
                                                     onclick='return saveNewGoal(
                                               "opt_Item_{$itemID}_UpdateMetrics",
                                                "opt_Item_{$itemID}_TrackAmount",
                                                "txt_Item_{$itemID}_StartAmount",
                                                "txt_Item_{$itemID}_TargetWhat",
                                                "txt_Item_{$itemID}_TargetAmount",
                                                "opt_Item_{$itemID}_NumberFormat",
                                                "opt_Item_{$itemID}_DisplayNumbers",
                                               "opt_Item_{$itemID}_Success","txt_Item_{$itemID}_Title",
                                                 "txt_Item_{$itemID}_Description",
                                                 "txt_Item_{$itemID}_StartDate",
                                                 "txt_Item_{$itemID}_EndDate",
                                                 "opt_Item_{$itemID}_Status",
                                                 "{$itemID}",
                                                 "span_item_{$itemID}_ErrorMessage", 
                                                 "div_CreateGoal",
                                                 "opt_Item_{$itemID}_LifeSpace","{$SourcePage}",
                                               "txt_Item_{normalize-space($itemID)}_ImageURL","{$OwnerID}", "{$ProjectID}");'
                                                     value="Save" style="margin-left:10px;"></input>
                                        <xsl:if test ="$SourcePage = 'ClientPortalNewProject'">
                                            <input type="button" class="button" value="Cancel" style="margin-left:10px;"
                                  onClick="return portal_AddNewClient('divGoalControl_New_Operations');">
                                            </input>
                                        </xsl:if>
                                        <xsl:if test ="$SourcePage = 'ClientPortal'">
                                            <input type="button" class="button" style="margin-left:10px;" onclick='return CloseCreateGoal("divClientPortalOperations_Container","{$SourcePage}","{$itemID}")' value="Cancel"></input>
                                        </xsl:if>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </xsl:if>
                    <xsl:if test ="$itemID = -99 or $itemID = 1">
                        <table width="100%">
                            <tr>
                                <td width="20%"></td>
                                <td width="60%">
                                    <div style="text-align: center;">
                                        <div style="margin-bottom: 20px;">
                                            <span class="labelHeader">
                                                Please select a lifespace for adding a new Goal
                                            </span>
                                        </div>
                                        <div style="text-align: center; width: 500px;">
                                            <table width="100%">
                                                <tr>
                                                    <td width="5%"></td>
                                                </tr>
                                                <tr>
                                                    <!--<xsl:variable name="tdWidth">
                                                        <xsl:if test ="count(CreateGoal/LifeSpaceList/LifeSpace/Item) = 4">
                                                            <xsl:text>22%</xsl:text>
                                                        </xsl:if>
                                                        <xsl:if test ="count(CreateGoal/LifeSpaceList/LifeSpace/Item) = 5">
                                                            <xsl:text>16%</xsl:text>
                                                        </xsl:if>
                                                        <xsl:if test ="count(CreateGoal/LifeSpaceList/LifeSpace/Item) = 6">
                                                            <xsl:text>15%</xsl:text>
                                                        </xsl:if>
                                                    </xsl:variable>-->
                                                    <xsl:for-each select="CreateGoal/LifeSpaceList/LifeSpace/Item">
                                                        <xsl:if test ="position() mod 5 = 1">
                                                            <tr>
                                                                <td width="50px">
                                                                    <xsl:call-template name="MyLifeSpace">
                                                                        <xsl:with-param name="TemplatePathURL" select="$TemplatePathURL"></xsl:with-param>
                                                                        <xsl:with-param name="RequestDivID" select="$RequestDivID"></xsl:with-param>
                                                                        <xsl:with-param name="Name" select="normalize-space(Name)"></xsl:with-param>
                                                                        <xsl:with-param name="ID" select="normalize-space(ID)"></xsl:with-param>
                                                                    </xsl:call-template>
                                                                </td>
                                                                <td width="50px">
                                                                    <xsl:call-template name="MyLifeSpace">
                                                                        <xsl:with-param name="TemplatePathURL" select="$TemplatePathURL"></xsl:with-param>
                                                                        <xsl:with-param name="RequestDivID" select="$RequestDivID"></xsl:with-param>
                                                                        <xsl:with-param name="Name" select="normalize-space(following-sibling::Item[1]/Name)"></xsl:with-param>
                                                                        <xsl:with-param name="ID" select="normalize-space(following-sibling::Item[1]/ID)"></xsl:with-param>
                                                                    </xsl:call-template>
                                                                </td>
                                                                <td width="50px">
                                                                    <xsl:call-template name="MyLifeSpace">
                                                                        <xsl:with-param name="TemplatePathURL" select="$TemplatePathURL"></xsl:with-param>
                                                                        <xsl:with-param name="RequestDivID" select="$RequestDivID"></xsl:with-param>
                                                                        <xsl:with-param name="Name" select="normalize-space(following-sibling::Item[2]/Name)"></xsl:with-param>
                                                                        <xsl:with-param name="ID" select="normalize-space(following-sibling::Item[2]/ID)"></xsl:with-param>
                                                                    </xsl:call-template>
                                                                </td>
                                                                <td width="50px">
                                                                    <xsl:call-template name="MyLifeSpace">
                                                                        <xsl:with-param name="TemplatePathURL" select="$TemplatePathURL"></xsl:with-param>
                                                                        <xsl:with-param name="RequestDivID" select="$RequestDivID"></xsl:with-param>
                                                                        <xsl:with-param name="Name" select="normalize-space(following-sibling::Item[3]/Name)"></xsl:with-param>
                                                                        <xsl:with-param name="ID" select="normalize-space(following-sibling::Item[3]/ID)"></xsl:with-param>
                                                                    </xsl:call-template>
                                                                </td>
                                                                <td width="50px">
                                                                    <xsl:call-template name="MyLifeSpace">
                                                                        <xsl:with-param name="TemplatePathURL" select="$TemplatePathURL"></xsl:with-param>
                                                                        <xsl:with-param name="RequestDivID" select="$RequestDivID"></xsl:with-param>
                                                                        <xsl:with-param name="Name" select="normalize-space(following-sibling::Item[4]/Name)"></xsl:with-param>
                                                                        <xsl:with-param name="ID" select="normalize-space(following-sibling::Item[4]/ID)"></xsl:with-param>
                                                                    </xsl:call-template>
                                                                </td>
                                                            </tr>
                                                            <!--<td style="text-align:center;" width="{normalize-space($tdWidth)}">-->

                                                            <!--</td>-->
                                                        </xsl:if>
                                                    </xsl:for-each>
                                                </tr>
                                                <tr>
                                                    <td width="5%"></td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                </td>
                                <td width="20%"></td>
                            </tr>
                        </table>
                    </xsl:if>
                </div>
            </div>
        </xsl:if>
    </xsl:template>

    <xsl:template name="MyLifeSpace">
        <xsl:param name="TemplatePathURL" select="'N/A'"/>
        <xsl:param name="RequestDivID" select="'N/A'"/>
        <xsl:param name="Name" select="'N/A'"/>
        <xsl:param name="ID" select="'N/A'"/>
        <xsl:if test="$ID &gt; 0">
            <div align="center" class="link"
                 onclick='return createNewGoal("{normalize-space($ID)}","{$RequestDivID}","","");'>
                <xsl:choose>
                    <xsl:when test="$ID &gt; 0 and $ID &lt;= 6">
                        <img src="{$TemplatePathURL}web/Images/{$Name}.jpg"
                             alt="{normalize-space($Name)}"
                             title="{normalize-space($Name)}"
                             onload='setWidthAndHeightImage(this,"50");'
                             onmouseover='return BorderOnMouseOver(true, this)'
                             onmouseout='return BorderOnMouseOver(false, this)'/>
                    </xsl:when>
                    <xsl:when test="$ID &gt; 6">
                        <img src="{$TemplatePathURL}Web/Images/LifeSpace LLC.jpg"
                             onload='setWidthAndHeightImage(this,"50");'
                             style="display:inline;" border="0"
                             onmouseover='return BorderOnMouseOver(true, this)'
                             onmouseout='return BorderOnMouseOver(false, this)'>
                        </img>
                    </xsl:when>
                </xsl:choose>
                <div>
                    <span align='center'>
                        <xsl:value-of select="$Name"/>
                    </span>
                </div>
            </div>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>
