﻿<?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:include href="Version_2_0/NumberMetricsTemplate.xslt"/>

    <xsl:template match="/">
        <xsl:variable name="TemplatePathURL" select="normalize-space(CreateGoal/TemplateURL)"/>
        <xsl:variable name="HostName" select="normalize-space(CreateGoal/HostName)"/>
        <xsl:variable name="itemID" select="normalize-space(CreateGoal/ItemID)"/>
        <xsl:variable name="item" select="normalize-space(CreateGoal/Item)"/>
        <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:variable name="GoalNumberDirectionXML" select="CreateGoal/GoalNumberDirectionXML/."></xsl:variable>
        <xsl:variable name="GoalNumberFormatXML" select="CreateGoal/GoalNumberFormatXML/."></xsl:variable>
        <xsl:variable name="GoalOpenControlXML" select="CreateGoal/GoalOpenControlXML/."></xsl:variable>
        <xsl:variable name="GoalNotesFormatXML" select="CreateGoal/GoalNotesFormatXML/."></xsl:variable>
        <xsl:variable name="UserBrandXML" select="CreateGoal/UserBrands/."></xsl:variable>
        <xsl:variable name="NumberGoalPermissionXML" select="CreateGoal/NumberGoalPermission/."></xsl:variable>
        <xsl:variable name="DefaultStartDate" select="CreateGoal/DefaultStartDate"></xsl:variable>
        <xsl:variable name="DefaultEndDate" select="CreateGoal/DefaultEndDate"></xsl:variable>
        <xsl:variable name="IsSecureConnection" select="CreateGoal/IsSecureConnection"></xsl:variable>

        <xsl:variable name="Protocol">
            <xsl:choose>
                <xsl:when test="$IsSecureConnection = 1">
                    <xsl:text>https://</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>http://</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:if test="$SourcePage = 'HomePage'">
            <div id="div_CreateGoal_{$itemID}" style="border: 1px solid #58595B; padding:10px;background:#F1F2F2;">
                <xsl:if test="$itemID != -99 and $itemID != 1">
                    <div id="div_GoalDefaultForm">
                        <table class="tableMaster">
                            <tr>
                                <td style="width: 90px;" class="textCenter">
                                    <div id="div_CustomGoalImage">
                                        <xsl:choose>
                                            <xsl:when test="$item = 'LifeSpace LLC'">
                                                <img border="0" style="height:90px;width:90px;" alt=""
                                              src="{$TemplatePathURL}Web/Images/LifeSpace LLC.jpg"></img>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <img border="0" style="height:90px;width:90px;" alt=""
                                              src="{$TemplatePathURL}Web/Images/Ver_2_0/goalDefault_{$item}.jpg"></img>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </div>
                                    <div class="divBrowseGradient marginTop5 onMouseOver" align="center"
										onClick="ImageUploader_PopupCenter('{$Protocol}{$HostName}/upload/uploadimage.aspx?guid=TempItemsGoals&amp;cropRatio=2&amp;requiredHeight=100&amp;requiredWidth=100&amp;requiredFileName=Thumbnail&amp;Key=UploadPathTempLocation&amp;UserID={$OwnerID}',
                                                                'Upload_Image','530','390','0','UploadGoalImage','div_CustomGoalImage',null,0);">
                                        <span class="spanBrowseGradientTextGray onMouseOver">UPLOAD IMAGE</span>
                                    </div>
                                    <input id="goalImagePath" type="hidden" class="text"/>
                                </td>
                                <td>
                                    <div class="marginLeft10">
                                        <input id="txt_Item_{$itemID}_Title" type="text" value="" class="textBoxAddGoal2" maxlength="50"/>
                                        <span id="span_item_{$itemID}_ErrorMessage" class="labelError" style="display:none;">*</span>
                                    </div>
                                    <div class="marginTop5 marginLeft10">
                                        <textarea id="txt_Item_{$itemID}_Description" rows="2" class="textAreaAddGoal">
                                        </textarea>
                                    </div>
                                </td>
                            </tr>
                            <tr style="height:5px;">
                                <td colspan="2"></td>
                            </tr>
                            <tr>
                                <td>
                                    <span class="goalUpdateLabel verticallyMiddle">Goal Type</span>
                                </td>
                                <td>
                                    <input id="rdb_{$itemID}_PersonalGoal" type="radio" name="GoalType" checked="checked"
                                           onclick="document.getElementById('tr_OpenTo').style.display='none';
                                                document.getElementById('tr_NotesFormat').style.display='none';                                    
                                                document.getElementById('tr_OwnerBrands') != null ? document.getElementById('tr_OwnerBrands').style.display='none' : '';
                                                document.getElementById('tr_JoinDeadline').style.display='none';">
                                        <span class="publicationSummary marginRight10">Personal Goal</span>
                                    </input>
                                    <input id="rdb_{$itemID}_GroupChallenge" type="radio" name="GoalType"
                                           onclick="document.getElementById('tr_OpenTo').style.display='table-row';
                                                document.getElementById('tr_NotesFormat').style.display='table-row';                                   
                                                document.getElementById('tr_OwnerBrands') != null ? document.getElementById('tr_OwnerBrands').style.display='table-row' : '';                                           
                                                document.getElementById('tr_JoinDeadline').style.display='table-row';" style="display:none;">
                                        <span class="publicationSummary" style="display:none;">Group Challenge</span>
                                    </input>
                                </td>
                            </tr>
                            <tr id="tr_OpenTo" style="display:none;">
                                <td>
                                    <span id="span_OpenTo_Text" class="goalUpdateLabel">Open To</span>
                                </td>
                                <td>
                                    <select id="opt_OpenTo_{$itemID}" class="smallDropdownGC">
                                        <xsl:for-each select="$GoalOpenControlXML/GoalOpenControl">
                                            <xsl:choose>
                                                <xsl:when test="GoalOpenTo = 'Public'">
                                                    <option value="{ID}" selected="selected">
                                                        <xsl:value-of select="GoalOpenTo"/>
                                                    </option>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <option value="{ID}">
                                                        <xsl:value-of select="GoalOpenTo"/>
                                                    </option>
                                                </xsl:otherwise>
                                            </xsl:choose>

                                        </xsl:for-each>
                                    </select>
                                </td>
                            </tr>
                            <tr id="tr_NotesFormat" style="display:none;">
                                <td>
                                    <span id="span_NotesFormat_Text" class="goalUpdateLabel">Notes Format</span>
                                </td>
                                <td>
                                    <select id="opt_NotesFormat_{$itemID}" class="smallDropdownGC">
                                        <xsl:for-each select="$GoalNotesFormatXML/GoalNotesFormat">
                                            <xsl:choose>
                                                <xsl:when test="NotesFormat = 'Facebook Social Comments'">
                                                    <option value="{ID}" selected="selected">
                                                        <xsl:value-of select="NotesFormat"/>
                                                    </option>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <option value="{ID}">
                                                        <xsl:value-of select="NotesFormat"/>
                                                    </option>
                                                </xsl:otherwise>
                                            </xsl:choose>

                                        </xsl:for-each>
                                    </select>
                                </td>
                            </tr>
                            <tr id="tr_JoinDeadline" style="display:none;">
                                <td>
                                    <span id="span_JoinDeadline_Text" class="goalUpdateLabel">Join Deadline</span>
                                </td>
                                <td>
                                    <input id="txt_Item_{$itemID}_JoinDeadline" type="text" onblur="checkdate(this)"
                                          style="width:75px;" class="text" value =""/>
                                    <img src="{normalize-space($TemplatePathURL)}Web/Images/big_spacer.gif" ></img>
                                    <img id="img_Item_{$itemID}_JoinDeadline" align="absmiddle" style="padding-bottom:4px;" class="onMouseOver"
                                         src="{normalize-space($TemplatePathURL)}Web/Images/Ver_2_0/BT_startDate.png" width="20" height="20"
                                         onclick='dp("txt_Item_{$itemID}_JoinDeadline", "img_Item_{$itemID}_JoinDeadline");'></img>
                                </td>
                            </tr>
                            <tr>
                                <td class="textLeft verticallyMiddle">
                                    <span class="goalUpdateLabel verticallyMiddle">Measure Success</span>
                                </td>
                                <td>
                                    <select class="verticallyMiddle smallDropdownSuccess marginRight15" id="opt_Item_{$itemID}_Success" name="lifespace"
											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>

                                    <span class="marginRight5 goalUpdateLabel verticallyMiddle">Start Date</span>

                                    <input class="marginRight5 date2 verticallyMiddle" id="txt_Item_{$itemID}_StartDate" type="text" onblur="checkdate(this)"
										   value =""/>

                                    <img class="marginRight10 verticallyMiddle onMouseOver" id="img_Item_{$itemID}_StartDate"
										 src="{normalize-space($TemplatePathURL)}Web/Images/Ver_2_0/BT_startDate.png"
										 onclick='dp("txt_Item_{$itemID}_StartDate", "img_Item_{$itemID}_StartDate");'></img>

                                    <span class="marginRight5 goalUpdateLabel verticallyMiddle">Finish Date</span>

                                    <input class="marginRight5 date2 verticallyMiddle" id="txt_Item_{$itemID}_EndDate" type="text" onblur="checkdate(this)"
										   runat="server" value =""/>

                                    <img class="verticallyMiddle onMouseOver" style="margin-bottom:4px;" id="img_Item_{$itemID}_EndDate"
										 src="{normalize-space($TemplatePathURL)}Web/Images/Ver_2_0/BT_endDate.png"
										 onclick='dp("txt_Item_{$itemID}_EndDate", "img_Item_{$itemID}_EndDate");'></img>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <div id="div_{$itemID}_DisplayNumbers" style="display:none;margin-left:-3px;">
                                        <table class="tableMaster">
                                            <tr>
                                                <td>
                                                    <span class="goalUpdateLabel">Target</span>
                                                </td>
                                                <td>
                                                    <span>
                                                        <select id ="opt_Item_{$itemID}_DisplayNumbers" name="lifespace" class="smallDropdown">
                                                            <xsl:for-each select="$GoalNumberDirectionXML/GoalNumberDirection">
                                                                <option value="{ID}">
                                                                    <xsl:value-of select="GoalNumberDirection"/>
                                                                </option>
                                                            </xsl:for-each>
                                                        </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");'>
                                                            <xsl:for-each select="$GoalNumberFormatXML/GoalNumberFormat">
                                                                <option value="{ID}">
                                                                    <xsl:value-of select="NumberFormat"/>
                                                                </option>
                                                            </xsl:for-each>
                                                        </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>
                                                    <span class="goalUpdateLabel">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>
                                                    <span class="goalUpdateLabel">Track Amount</span>
                                                </td>
                                                <td>
                                                    <select id ="opt_Item_{$itemID}_TrackAmount"
															name="lifespace" class="smallDropdown">
                                                        <xsl:call-template name="NumberUpdateMetrics">
                                                            <xsl:with-param name="Metrics">
                                                                <xsl:text>Monthly</xsl:text>
                                                            </xsl:with-param>
                                                        </xsl:call-template>                                                        
                                                        <!--<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>
                                                    <span class="goalUpdateLabel">Update Metrics</span>
                                                </td>
                                                <td>
                                                    <select id ="opt_Item_{$itemID}_UpdateMetrics" name="lifespace" class="smallDropdown">
                                                        <xsl:call-template name="NumberUpdateMetrics">
                                                            <xsl:with-param name="Metrics">
                                                                <xsl:text>Weekly</xsl:text>
                                                            </xsl:with-param>
                                                        </xsl:call-template>
                                                        <!--<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 test ="$itemID  = -99 or $itemID = 1">
                                <tr>
                                    <td>
                                        <span class="goalUpdateLabel">Link to:</span>
                                    </td>
                                    <td>
                                        <select id="opt_Item_{$itemID}_LifeSpace" name="lifespace" class="smallDropdown">
                                            <xsl:for-each select="CreateGoal/LifeSpaceList/LifeSpace/Item">
                                                <xsl:choose>
                                                    <xsl:when  test="Name = 'Fitness'">
                                                        <option value="{ID/.}" selected="selected">
                                                            <xsl:value-of select="Name/."/>
                                                        </option>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <option value="{ID/.}">
                                                            <xsl:value-of select="Name/."/>
                                                        </option>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                                
                                                
                                                <!--<option value="{ID/.}">
                                                    <xsl:value-of select="normalize-space(Name/.)"/>
                                                </option>-->
                                            </xsl:for-each>
                                        </select>
                                    </td>
                                </tr>
                            </xsl:if>
                            <tr>
                                <td class="textLeft verticallyMiddle">
                                    <span class="goalUpdateLabel verticallyMiddle" 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>

                            <xsl:choose>
                                <xsl:when test="count($UserBrandXML/Brand[BrandStatusID != 11]) &gt; 1">
                                    <tr id="tr_OwnerBrands" style="display:none;">
                                        <td class="textLeft verticallyMiddle">
                                            <span class="goalUpdateLabel verticallyMiddle">Link to Company</span>
                                        </td>
                                        <td>
                                            <select id="ddl_Item_{$itemID}_UserBrands" class="smallDropdown" style="width:110px;">
                                                <option></option>
                                                <xsl:for-each select="$UserBrandXML/Brand[BrandStatusID != 11]">
                                                    <xsl:sort data-type="text" order="ascending" select="CompanyName"/>
                                                    <option value="{BrandID}">
                                                        <xsl:value-of select="normalize-space(CompanyName)"/>
                                                    </option>
                                                </xsl:for-each>
                                            </select>
                                        </td>
                                    </tr>
                                </xsl:when>
                                <xsl:otherwise>
                                    <tr style="display:none;">
                                        <td class="textLeft verticallyMiddle">
                                            <span class="goalUpdateLabel verticallyMiddle">Link to Company</span>
                                        </td>
                                        <td>
                                            <select id="ddl_Item_{$itemID}_UserBrands" class="smallDropdown" style="width:110px;">
                                                <option value="-99"></option>
                                                <xsl:for-each select="$UserBrandXML/Brand">
                                                    <xsl:sort data-type="text" order="ascending" select="CompanyName"/>
                                                    <option value="{BrandID}" selected="selected">
                                                        <xsl:value-of select="normalize-space(CompanyName)"/>
                                                    </option>
                                                </xsl:for-each>
                                            </select>
                                        </td>
                                    </tr>
                                </xsl:otherwise>
                            </xsl:choose>
                            <tr id="tr_numbersEnteredBy" style="display:none;">
                                <td class="textLeft verticallyMiddle">
                                    <span class="goalUpdateLabel verticallyMiddle">Numbers Entered By</span>
                                </td>
                                <td>
                                    <select id="ddl_NumbersEnteredBy" class="smallDropdown" style="width:110px;">
                                        <option value="-99">-Select-</option>
                                        <xsl:for-each select="$NumberGoalPermissionXML/Permission">
                                            <xsl:choose>
                                                <xsl:when test="ID = 1">
                                                    <option value="{ID}" selected="selected">
                                                        <xsl:value-of select="NumbersEnteredBy"/>
                                                    </option>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <option value="{ID}">
                                                        <xsl:value-of select="NumbersEnteredBy"/>
                                                    </option>
                                                </xsl:otherwise>
                                            </xsl:choose>

                                        </xsl:for-each>
                                    </select>
                                </td>
                            </tr>
                        </table>
                        <div align="right" class="padding10">
                            <table cellpadding="0" cellspacing="0">
                                <tr>
                                    <td class="textCenter onMouseOver divBrowseGradient spanBrowseGradientTextGray verticallyMiddle" style="width:80px;height:30px;"
										onclick="return CloseCreateGoal('div_CreateGoal_{$itemID}', '{$SourcePage}','{$itemID}');"
											  onmouseover="document.getElementById('img_Cancel_{$itemID}').src='{$TemplatePathURL}Web/Images/Ver_2_0/BT_x_hover.png';"
											  onmouseout="document.getElementById('img_Cancel_{$itemID}').src='{$TemplatePathURL}Web/Images/Ver_2_0/BT_x.png';">
                                        <span id="span_Cancel_{$itemID}" class="capitalFont marginRight5 verticallyMiddle">CANCEL</span>
                                        <img id="img_Cancel_{$itemID}" src="{$TemplatePathURL}Web/Images/Ver_2_0/BT_x.png" align="absmiddle"></img>
                                    </td>
                                    <td width="8px"></td>
                                    <td class="textCenter onMouseOver divBrowseGradient spanBrowseGradientTextGray verticallyMiddle" style="width:80px;height:30px;"
										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}","goalImagePath", "{$OwnerID}","{$ProjectID}","","rdb_{$itemID}_PersonalGoal","rdb_{$itemID}_GroupChallenge",
                                           "opt_OpenTo_{$itemID}","opt_NotesFormat_{$itemID}","txt_Item_{$itemID}_JoinDeadline", "ddl_NumbersEnteredBy");'
										  onmouseover="document.getElementById('img_Save_{$itemID}').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_add_over.png';"
										  onmouseout="document.getElementById('img_Pause_{$itemID}').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png';">
                                        <span id="span_Pause_{$itemID}" class="capitalFont verticallyMiddle marginRight5">save</span>
                                        <img id="img_Pause_{$itemID}" src="{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle"></img>

                                    </td>
                                </tr>
                            </table>
                        </div>
                    </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>
        </xsl:if>
        <xsl:if test="normalize-space(CreateGoal/SourcePage) != 'HomePage'">
            <xsl:variable name ="divMargin">
                <xsl:choose>
                    <xsl:when test ="normalize-space(CreateGoal/SourcePage) = 'ClientPortalNewProject' or normalize-space(CreateGoal/SourcePage) = 'PortalAddGoalFromWizard'
                                            or normalize-space(CreateGoal/SourcePage) = 'AddGoalFromDashboard'">0px</xsl:when>
                    <xsl:otherwise>
                        <xsl:text>30px</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            
            <div id="div_CreateGoal">
                <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="packageTitle">
                                    Create your own goal manually by using this form:
                                </span>
                            </div>
                            <table class="tableMaster">
                                <tr>
                                    <td style="width: 20%;">
                                        <span class="packageTitle">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="packageTitle">Description</span>
                                    </td>
                                    <td>
                                        <textarea id="txt_Item_{$itemID}_Description" rows="2" class="textArea">
                                        </textarea>
                                    </td>
                                </tr>

                                <tr>
                                    <td>
                                        <span class="packageTitle">Goal Type</span>
                                    </td>
                                    <td>
                                        <input id="rdb_{$itemID}_PersonalGoal" type="radio" name="GoalType" checked="checked"
                                               onclick="document.getElementById('tr_OpenTo').style.display='none';
                                                            document.getElementById('tr_NotesFormat').style.display='none';
                                                            document.getElementById('tr_numbersEnteredBy').style.display='none';
                                                            document.getElementById('tr_OwnerBrands') != null ? document.getElementById('tr_OwnerBrands').style.display='none' : '';
                                                            document.getElementById('tr_JoinDeadline').style.display='none';">
                                            <span class="publicationSummary marginRight10">Personal Goal</span>
                                        </input>
                                        <input id="rdb_{$itemID}_GroupChallenge" type="radio" name="GoalType"
                                               onclick="document.getElementById('tr_OpenTo').style.display='table-row';
                                                            document.getElementById('tr_NotesFormat').style.display='table-row';  
                                                            document.getElementById('tr_numbersEnteredBy').style.display='table-row';
                                                            document.getElementById('tr_OwnerBrands') != null ? document.getElementById('tr_OwnerBrands').style.display='table-row' : '';                                           
                                                            document.getElementById('tr_JoinDeadline').style.display='table-row';
                                                            document.getElementById('opt_Item_{$itemID}_Success').selectedIndex='1';
                                                            setSuccessKeyDisplay('opt_Item_{$itemID}_Success', 'div_{$itemID}_DisplayNumbers');" style="display:none;">
                                            <span class="publicationSummary" style="display:none;">Group Challenge</span>
                                        </input>
                                    </td>
                                </tr>
                                <tr id="tr_OpenTo" style="display:none;">
                                    <td>
                                        <span id="span_OpenTo_Text" class="packageTitle">Open To</span>
                                    </td>
                                    <td>
                                        <select id="opt_OpenTo_{$itemID}" class="smallDropdownGC">
                                            <xsl:for-each select="$GoalOpenControlXML/GoalOpenControl">
                                                <xsl:choose>
                                                    <xsl:when test="GoalOpenTo = 'Public'">
                                                        <option value="{ID}" selected="selected">
                                                            <xsl:value-of select="GoalOpenTo"/>
                                                        </option>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <option value="{ID}">
                                                            <xsl:value-of select="GoalOpenTo"/>
                                                        </option>
                                                    </xsl:otherwise>
                                                </xsl:choose>

                                            </xsl:for-each>
                                        </select>
                                    </td>
                                </tr>
                                <tr id="tr_NotesFormat" style="display:none;">
                                    <td>
                                        <span id="span_NotesFormat_Text" class="packageTitle">Notes Format</span>
                                    </td>
                                    <td>
                                        <select id="opt_NotesFormat_{$itemID}" class="smallDropdownGC">
                                            <xsl:for-each select="$GoalNotesFormatXML/GoalNotesFormat">
                                                <xsl:choose>
                                                    <xsl:when test="NotesFormat = 'Facebook Social Comments'">
                                                        <option value="{ID}" selected="selected">
                                                            <xsl:value-of select="NotesFormat"/>
                                                        </option>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <option value="{ID}">
                                                            <xsl:value-of select="NotesFormat"/>
                                                        </option>
                                                    </xsl:otherwise>
                                                </xsl:choose>

                                            </xsl:for-each>
                                        </select>
                                    </td>
                                </tr>
                                <tr id="tr_JoinDeadline" style="display:none;">
                                    <td>
                                        <span id="span_JoinDeadline_Text" class="packageTitle">Join Deadline</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{$itemID}_JoinDeadline" type="text" onblur="checkdate(this)"
                                              style="width:75px;" class="text" value =""/>
                                        <img src="{normalize-space($TemplatePathURL)}Web/Images/big_spacer.gif" ></img>
                                        <img id="img_Item_{$itemID}_JoinDeadline" align="absmiddle" style="padding-bottom:4px;" class="onMouseOver"
                                             src="{normalize-space($TemplatePathURL)}Web/Images/Ver_2_0/BT_startDate.png" width="20" height="20"
                                             onclick='dp("txt_Item_{$itemID}_JoinDeadline", "img_Item_{$itemID}_JoinDeadline");'></img>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <span class="packageTitle">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: 15%;">
                                                        <span class="packageTitle">Target</span>
                                                    </td>
                                                    <td>
                                                        <span>
                                                            <span>
                                                                <select id ="opt_Item_{$itemID}_DisplayNumbers" name="lifespace" class="smallDropdown">
                                                                    <xsl:for-each select="$GoalNumberDirectionXML/GoalNumberDirection">
                                                                        <option value="{ID}">
                                                                            <xsl:value-of select="GoalNumberDirection"/>
                                                                        </option>
                                                                    </xsl:for-each>
                                                                </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");'>
                                                                    <xsl:for-each select="$GoalNumberFormatXML/GoalNumberFormat">
                                                                        <option value="{ID}">
                                                                            <xsl:value-of select="NumberFormat"/>
                                                                        </option>
                                                                    </xsl:for-each>
                                                                </select>
                                                            </span>&#xa0;
                                                        </span>
                                                        <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="packageTitle">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="packageTitle">Track Amount</span>
                                                    </td>
                                                    <td>
                                                        <select id ="opt_Item_{$itemID}_TrackAmount"
                                                                name="lifespace" class="smallDropdown">
                                                            <xsl:call-template name="NumberUpdateMetrics">
                                                                <xsl:with-param name="Metrics">
                                                                    <xsl:text>Monthly</xsl:text>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                            <!--<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="packageTitle">Update Metrics</span>
                                                    </td>
                                                    <td>
                                                        <select id ="opt_Item_{$itemID}_UpdateMetrics" name="lifespace" class="smallDropdown">
                                                            <xsl:call-template name="NumberUpdateMetrics">
                                                                <xsl:with-param name="Metrics">
                                                                    <xsl:text>Weekly</xsl:text>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                            <!--<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="packageTitle">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="packageTitle">Link to:</span>
                                        </td>
                                        <td>
                                            <select id ="opt_Item_{$itemID}_LifeSpace" name="lifespace" class="smallDropdown">
                                                <xsl:for-each select="CreateGoal/LifeSpaceList/LifeSpace/Item">
                                                    <xsl:choose>
                                                        <xsl:when  test="Name = 'Fitness'">
                                                            <option value="{ID/.}" selected="selected">
                                                                <xsl:value-of select="Name/."/>
                                                            </option>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <option value="{ID/.}">
                                                                <xsl:value-of select="Name/."/>
                                                            </option>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:for-each>
                                            </select>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <tr>
                                    <td>
                                        <span class="packageTitle">Start Date</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{$itemID}_StartDate" type="text" onblur="checkdate(this)"
                                               class="date" value ="{$DefaultStartDate}"/>
                                        <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="packageTitle">End Date</span>
                                    </td>
                                    <td>
                                        <input id="txt_Item_{$itemID}_EndDate" type="text" onblur="checkdate(this)"
                                               runat="server" class="date" value ="{$DefaultEndDate}"/>
                                        <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="packageTitle"  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>
                                <xsl:choose>
                                    <xsl:when test="count($UserBrandXML/Brand[BrandStatusID != 11]) &gt; 1">
                                        <tr id="tr_OwnerBrands" style="display:none;">
                                            <td class="textLeft verticallyMiddle">
                                                <span class="packageTitle">Link to Company</span>
                                            </td>
                                            <td>
                                                <select id="ddl_Item_{$itemID}_UserBrands" class="smallDropdown" style="width:110px;">
                                                    <option></option>
                                                    <xsl:for-each select="$UserBrandXML/Brand[BrandStatusID != 11]">
                                                        <xsl:sort data-type="text" order="ascending" select="CompanyName"/>
                                                        <option value="{BrandID}">
                                                            <xsl:value-of select="normalize-space(CompanyName)"/>
                                                        </option>
                                                    </xsl:for-each>
                                                </select>
                                            </td>
                                        </tr>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <tr style="display:none;">
                                            <td class="textLeft verticallyMiddle">
                                                <span class="packageTitle">Link to Company</span>
                                            </td>
                                            <td>
                                                <select id="ddl_Item_{$itemID}_UserBrands" class="smallDropdown" style="width:110px;">
                                                    <option value="-99"></option>
                                                    <xsl:for-each select="$UserBrandXML/Brand">
                                                        <xsl:sort data-type="text" order="ascending" select="CompanyName"/>
                                                        <option value="{BrandID}" selected="selected">
                                                            <xsl:value-of select="normalize-space(CompanyName)"/>
                                                        </option>
                                                    </xsl:for-each>
                                                </select>
                                            </td>
                                        </tr>
                                    </xsl:otherwise>
                                </xsl:choose>
                                <tr id="tr_numbersEnteredBy" style="display:none;">
                                    <td class="textLeft verticallyMiddle">
                                        <span class="packageTitle">Numbers Entered By</span>
                                    </td>
                                    <td>
                                        <select id="ddl_NumbersEnteredBy" class="smallDropdown" style="width:110px;">
                                            <option value="-99">-Select-</option>
                                            <xsl:for-each select="$NumberGoalPermissionXML/Permission">
                                                <xsl:choose>
                                                    <xsl:when test="ID = 1">
                                                        <option value="{ID}" selected="selected">
                                                            <xsl:value-of select="NumbersEnteredBy"/>
                                                        </option>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <option value="{ID}">
                                                            <xsl:value-of select="NumbersEnteredBy"/>
                                                        </option>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </xsl:for-each>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:80px;line-height:30px;"
                                            onmouseover="document.getElementById('img_Add1_Save').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_add_over.png';"
                                            onmouseout="document.getElementById('img_Add1_Save').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png';"
                                            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}","","rdb_{$itemID}_PersonalGoal","rdb_{$itemID}_GroupChallenge",
                                               "opt_OpenTo_{$itemID}","opt_NotesFormat_{$itemID}","txt_Item_{$itemID}_JoinDeadline", "ddl_NumbersEnteredBy");'>
                                            <img id="img_Add1_Save" src="{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
                                            <span id="span_Cancel">
                                                SAVE
                                            </span>
                                        </div>
                                    </td>
                                    <td>
                                        <xsl:if test ="$SourcePage = 'ClientPortalNewProject' or $SourcePage = 'PortalAddGoalFromWizard' or $SourcePage = 'AddGoalFromDashboard'">
                                            <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:80px;line-height:30px;"
                                                onmouseover="document.getElementById('img_Add2_Cancel').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_add_over.png';"
                                                onmouseout="document.getElementById('img_Add2_Cancel').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png';"
                                                onClick="portal_AddNewClient('divGoalControl_New_Operations');closePopupWhiteLayerContainer();">
                                                <img id="img_Add2_Cancel" src="{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
                                                <span id="span_Cancel">
                                                    CANCEL
                                                </span>
                                            </div>
                                        </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>-->


                                            <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:80px;line-height:30px;"
                                               onmouseover="document.getElementById('img_Add2_Cancel').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_add_over.png';"
                                               onmouseout="document.getElementById('img_Add2_Cancel').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png';"
                                               onClick='CloseCreateGoal("divClientPortalOperations_Container","{$SourcePage}","{$itemID}");closePopupWhiteLayerContainer();'>
                                                <img id="img_Add2_Cancel" src="{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
                                                <span id="span_Cancel">
                                                    CANCEL
                                                </span>
                                            </div>
                                        </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: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>
