﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">

    <xsl:import href="CoachesShareIT.xslt"/>
    <xsl:import href="ParticipantsShareIT.xslt"/>
    <xsl:import href="ObserversShareIT.xslt"/>
    <xsl:import href="AutoSuggestVer11.xslt"/>
    <xsl:import href="../Version_2_0/ShareItListTemplate.xslt"/>
    <xsl:include href="../SendInvite.xslt"/>


    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="/">
        <xsl:call-template name="GoalShareIT">
            <xsl:with-param name="GoalItemID" select="ShareITRecords/SourceID"></xsl:with-param>
            <xsl:with-param name="Origin" select="ShareITRecords/Origin"></xsl:with-param>
            <xsl:with-param name="ShareITRecords" select="ShareITRecords/."></xsl:with-param>
            <xsl:with-param name="Permissions" select="ShareITRecords/Permissions/."></xsl:with-param>
            <xsl:with-param name="PortalItemID" select="ShareITRecords/PortalItemID"></xsl:with-param>
            <xsl:with-param name="PortalName" select="ShareITRecords/PortalName"></xsl:with-param>
            <xsl:with-param name="LifespaceID" select="ShareITRecords/LifespaceID"></xsl:with-param>
            <xsl:with-param name="BrandID" select="ShareITRecords/BrandID"></xsl:with-param>
            <xsl:with-param name="TemplateURL" select="ShareITRecords/TemplateURL"></xsl:with-param>
            <xsl:with-param name="UserID" select="ShareITRecords/UserID"></xsl:with-param>
            <xsl:with-param name="IsSecureConnection" select="ShareITRecords/IsSecureConnection"></xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="GoalShareIT">
        <xsl:param name="GoalItemID" select="'N/A'"></xsl:param>
        <xsl:param name="Origin" select="'N/A'"></xsl:param>
        <xsl:param name="ShareITRecords" select="'N/A'"></xsl:param>
        <xsl:param name="Permissions" select="'N/A'"></xsl:param>
        <xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
        <xsl:param name="PortalName" select="'N/A'"></xsl:param>
        <xsl:param name="LifespaceID" select="'N/A'"></xsl:param>
        <xsl:param name="BrandID" select="'N/A'"></xsl:param>
        <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
        <xsl:param name="UserID" select="'N/A'"></xsl:param>
        <xsl:param name="UserRoles" select="ShareITRecords/UserRoles/."></xsl:param>
        <xsl:param name="IsSecureConnection" select="'N/A'"></xsl:param>

        <xsl:variable name="PermissionID" select="$ShareITRecords/ShareIT[ID=$UserID]/PermissionID"></xsl:variable>

        <div id="divGoalShareIT_{$GoalItemID}" class="paddingBottom20">

            <xsl:variable name="CoachesRecords">
                <xsl:copy-of select ="$ShareITRecords/ShareIT[Coach = 1]"></xsl:copy-of>
            </xsl:variable>
            <xsl:variable name="ParticipantsRecords">
                <xsl:copy-of  select ="$ShareITRecords/ShareIT[Participant = 1]"></xsl:copy-of>
            </xsl:variable>
            <xsl:variable name="ObserverRecords">
                <xsl:copy-of  select ="$ShareITRecords/ShareIT[Observer = 1]"></xsl:copy-of>
            </xsl:variable>

            <div class="padding15">
                <img src="{$TemplateURL}Web/Images/Ver_2_0/icon_team_goal.png" class="verticallyMiddle marginLeft10 marginRight10"></img>
                <span class="actionDetailTitle verticallyMiddle">
                    Invite Others to This Goal
                </span>
            </div>
            <!--<div>
                <img style="width:550px;height:10px;" class="verticallyMiddle" src="{$TemplateURL}Web/Images/Ver_2_0/dropshadow_550.png"></img>
            </div>-->
            <table class="tableMaster" cellspacing="0" cellpadding="0">
                <tr>
                    <td style="width:380px;">
                        <div class="labelGoalTitle paddingBottom10 paddingLeft5 marginBottom10" style="border-bottom:1px solid gray;">
                            <span>Add Team Members</span>
                        </div>

                        <div class="divNoteGradient paddingLeft10 paddingRight10" id="div_SendInvite_{$GoalItemID}"
                             style="padding-top:40px;padding-bottom:30px;">

                            <div class="capitalFont marginLeft10">
                                <span class="labelGoalActionsText">ENTER NAMES OR EMAIL ADDRESSES BELOW</span>
                            </div>
                            <div id="div_permissionRDB_{$GoalItemID}" class="marginBottom10 marginLeft5 marginTop10">
                                <input id="rb_Participant_{$GoalItemID}" name="userType_{$GoalItemID}" type="radio"
                                       onClick="document.getElementById('div_AutoSuggest_{$GoalItemID}').style.display = 'block';
                                                displayAutoSuggestUser('{$GoalItemID}');">
                                    <span class="myTeamText">Participant</span>
                                </input>
                                <xsl:if test="$PermissionID &gt;= 4">
                                    <input id="rb_Coach_{$GoalItemID}" name="userType_{$GoalItemID}" type="radio"
                                           onClick="document.getElementById('div_AutoSuggest_{$GoalItemID}').style.display = 'none';
                                                displayAutoSuggestUser('{$GoalItemID}');">
                                        <span class="myTeamText">Coach/Manager</span>
                                    </input>
                                </xsl:if>
                                <input id="rb_Observer_{$GoalItemID}" name="userType_{$GoalItemID}" type="radio"
                                       onClick="document.getElementById('div_AutoSuggest_{$GoalItemID}').style.display = 'block';
                                                displayAutoSuggestUser('{$GoalItemID}');">
                                    <span class="myTeamText">Observer</span>
                                </input>
                            </div>
                            <div id="div_Participant_{$GoalItemID}_AutoSuggest" style="display:block;">
                                <xsl:call-template name="AutoSuggestVer11">
                                    <xsl:with-param name="SourceID" select="$GoalItemID"></xsl:with-param>
                                    <xsl:with-param name="TargetDivID">
                                        <xsl:text>div_shareIt_</xsl:text>
                                        <xsl:value-of select="$GoalItemID"/>
                                        <xsl:text>_participant</xsl:text>
                                    </xsl:with-param>
                                    <xsl:with-param name="Origin">
                                        <xsl:text>ParticipantShareIt_2_0</xsl:text>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </div>
                            <div id="div_Coach_{$GoalItemID}_AutoSuggest" style="display:none;">
                                <xsl:call-template name="AutoSuggestVer11">
                                    <xsl:with-param name="SourceID" select="$GoalItemID"></xsl:with-param>
                                    <xsl:with-param name="TargetDivID">
                                        <xsl:text>div_shareIt_</xsl:text>
                                        <xsl:value-of select="$GoalItemID"/>
                                        <xsl:text>_coaches</xsl:text>
                                    </xsl:with-param>
                                    <xsl:with-param name="Origin">
                                        <xsl:text>CoachesShareIt_2_0</xsl:text>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </div>
                            <div id="div_Observer_{$GoalItemID}_AutoSuggest" style="display:none;">
                                <xsl:call-template name="AutoSuggestVer11">
                                    <xsl:with-param name="SourceID" select="$GoalItemID"></xsl:with-param>
                                    <xsl:with-param name="TargetDivID">
                                        <xsl:text>div_shareIt_</xsl:text>
                                        <xsl:value-of select="$GoalItemID"/>
                                        <xsl:text>_observer</xsl:text>
                                    </xsl:with-param>
                                    <xsl:with-param name="Origin">
                                        <xsl:text>ObserverShareIt_2_0</xsl:text>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </div>
                            <div align="right" class="marginTop20" style="display:block;">
                                <div id="div_Participant_{$GoalItemID}_Submit" class="divGradientButton spanGradientText verticallyMiddle lineHeight30" style="width:90px;display:table-Cell;"
								  onmouseover="document.getElementById('div_Participant_{$GoalItemID}_SubmitImage').src='{$TemplateURL}/web/images/ver_2_0/BT_arrow_hover.png';"
								  onmouseout="document.getElementById('div_Participant_{$GoalItemID}_SubmitImage').src='{$TemplateURL}/web/images/ver_2_0/BT_arrow.png';"
								  onclick='return brandAutoSuggest_selectAutoSuggestFromAutoSuggestTextBox_OnButton("{$GoalItemID}",
                                                    "div_shareIt_{$GoalItemID}_participant_txt_shareIt_{$GoalItemID}_Add_New", 
                                                    "ParticipantShareIt_2_0",
                                                    "div_shareIt_{$GoalItemID}_participant",
                                                    "div_shareIt_{$GoalItemID}_participant_Suggestions");'>
                                    <img alt="" id="div_Participant_{$GoalItemID}_SubmitImage" class="verticallyMiddle marginRight5"
										 src="{$TemplateURL}/web/images/ver_2_0/BT_arrow.png"></img>
                                    <span class="verticallyMiddle">
                                        Submit
                                    </span>
                                </div>
                            </div>
                            <div id="div_Coach_{$GoalItemID}_Submit" align="right" class="marginTop20" style="display:none;">
                                <div class="divGradientButton spanGradientText verticallyMiddle" style="width:90px;display:table-Cell;"
									 onmouseover="document.getElementById('div_Coach_{$GoalItemID}_SubmitImage').src='{$TemplateURL}/web/images/ver_2_0/BT_arrow_hover.png';"
									 onmouseout="document.getElementById('div_Coach_{$GoalItemID}_SubmitImage').src='{$TemplateURL}/web/images/ver_2_0/BT_arrow.png';"
									 onclick='return brandAutoSuggest_selectAutoSuggestFromAutoSuggestTextBox_OnButton("{$GoalItemID}",
                                                    "div_shareIt_{$GoalItemID}_coaches_txt_shareIt_{$GoalItemID}_Add_New", 
                                                    "CoachesShareIt_2_0",
                                                    "div_shareIt_{$GoalItemID}_coach",
                                                    "div_shareIt_{$GoalItemID}_coach_Suggestions");'>
                                    <img alt="" id="div_Coach_{$GoalItemID}_SubmitImage" class="verticallyMiddle marginRight5"
										 src="{$TemplateURL}/web/images/ver_2_0/BT_arrow.png"></img>
                                    <span class="verticallyMiddle">
                                        Submit
                                    </span>
                                </div>
                            </div>
                            <div id="div_Observer_{$GoalItemID}_Submit" align="right" class="marginTop20" style="display:none;">
                                <div class="divGradientButton spanGradientText verticallyMiddle" style="width:90px;display:table-Cell;"
									 onmouseover="document.getElementById('div_Observer_{$GoalItemID}_SubmitImage').src='{$TemplateURL}/web/images/ver_2_0/BT_arrow_hover.png';"
									 onmouseout="document.getElementById('div_Observer_{$GoalItemID}_SubmitImage').src='{$TemplateURL}/web/images/ver_2_0/BT_arrow.png';"
									 onclick='return brandAutoSuggest_selectAutoSuggestFromAutoSuggestTextBox_OnButton("{$GoalItemID}",
                                                    "div_shareIt_{$GoalItemID}_observer_txt_shareIt_{$GoalItemID}_Add_New", 
                                                    "ObserverShareIt_2_0",
                                                    "div_shareIt_{$GoalItemID}_observer",
                                                    "div_shareIt_{$GoalItemID}_observer_Suggestions");'>
                                    <img alt="" id="div_Observer_{$GoalItemID}_SubmitImage" class="verticallyMiddle marginRight5"
										 src="{$TemplateURL}/web/images/ver_2_0/BT_arrow.png"></img>
                                    <span class="verticallyMiddle">
                                        Submit
                                    </span>
                                </div>
                            </div>
                        </div>

                        <div class="marginTop25 paddingLeft5" style="border-bottom:1px solid gray;">
                            <span class="labelGoalTitle  verticallyMiddle">
                                Get Help
                            </span>
                        </div>
                        <div id="divCoachShareDisplay_{$GoalItemID}" align="right" class="marginTop10" style="width:100%;">
                            <div class="padding5">
                                <textArea id="txtArea_{$GoalItemID}_Request" class="textAreaBox"
                                          onfocus="SetTextAreaValue(this.id, 'Enter Your Request...', 'focus');" 
                                          onblur="SetTextAreaValue(this.id, 'Enter Your Request...', 'blur');" 
                                          defaulttext="Enter Your Request..." >
                                    <xsl:text>Enter Your Request...</xsl:text>
                                </textArea>
                            </div>
                            <div class="marginTop10">
                                <xsl:if test="$UserRoles and count($UserRoles/Role[RoleName = 'Brand Admin']) &gt; 0">
                                    <div id="div_{$GoalItemID}_AddMeAsCoach" class="divGradientButton spanGradientText marginLeft10 lineHeight30" style="width:90px;float:left;"
                                         onmouseover="document.getElementById('div_{$GoalItemID}_AddMeAsCoachImage').src='{$TemplateURL}/web/images/ver_2_0/BT_arrow_hover.png';"
                                         onmouseout="document.getElementById('div_{$GoalItemID}_AddMeAsCoachImage').src='{$TemplateURL}/web/images/ver_2_0/BT_arrow.png';"
                                         onClick="clientPortal_OpenProjectAddMe('{$GoalItemID}', 'div_{$GoalItemID}_AddMeAsCoach', 'AddCoachOnGoal');">
                                        <img alt="" id="div_{$GoalItemID}_AddMeAsCoachImage" class="verticallyMiddle marginRight5"
                                             src="{$TemplateURL}/web/images/ver_2_0/BT_arrow.png"></img>
                                        <span class="verticallyMiddle">
                                            Add Me
                                        </span>
                                    </div>
                                </xsl:if>
                                <div id="div_sendRequest_{$GoalItemID}_Submit" class="divGradientButton spanGradientText lineHeight30" style="width:120px;"
                                     onmouseover="document.getElementById('div_sendRequest_{$GoalItemID}_SubmitImage').src='{$TemplateURL}/web/images/ver_2_0/BT_arrow_hover.png';"
                                     onmouseout="document.getElementById('div_sendRequest_{$GoalItemID}_SubmitImage').src='{$TemplateURL}/web/images/ver_2_0/BT_arrow.png';"
                                     onClick="coachesShare_NotifyCoachLearnMore_Ver_2_0({$GoalItemID});">
                                    <img alt="" id="div_sendRequest_{$GoalItemID}_SubmitImage" class="verticallyMiddle marginRight5"
                                             src="{$TemplateURL}/web/images/ver_2_0/BT_arrow.png"></img>
                                    <span class="verticallyMiddle">
                                        Send Request
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div id="divCoachShareHide_{$GoalItemID}" class="padding10 textRight" style="display:none;">
                            <span class="Label">
                                Thank you!  We will contact you shortly.
                            </span>
                        </div>
                    </td>
                    <td style="width:420px;">
                        <xsl:call-template name="MyTeam">
                            <xsl:with-param name="ShareITRecords" select="$ShareITRecords"></xsl:with-param>
                            <xsl:with-param name="GoalItemID" select="$GoalItemID"></xsl:with-param>
                            <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                            <xsl:with-param name="UserID" select="$UserID"></xsl:with-param>
                            <xsl:with-param name="PermissionID" select="$PermissionID"></xsl:with-param>
                            <xsl:with-param name="Permissions" select="$Permissions"></xsl:with-param>
                            <xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
                        </xsl:call-template>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template name="MyTeam">
        <xsl:param name="ShareITRecords" select="'N/A'"></xsl:param>
        <xsl:param name="GoalItemID" select="'N/A'"></xsl:param>
        <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
        <xsl:param name="UserID" select="'N/A'"></xsl:param>
        <xsl:param name="PermissionID" select="'N/A'"></xsl:param>
        <xsl:param name="Permissions" select="'N/A'"></xsl:param>
        <xsl:param name="IsSecureConnection" select="'N/A'"></xsl:param>

        <xsl:variable name="CoachShareITRec">
            <xsl:copy-of  select ="$ShareITRecords/ShareIT[Coach = 1]"></xsl:copy-of>
        </xsl:variable>
        <xsl:variable name="ParticipantShareITRec">
            <xsl:copy-of  select ="$ShareITRecords/ShareIT[Participant = 1]"></xsl:copy-of>
        </xsl:variable>
        <xsl:variable name="ObserverShareITRec">
            <xsl:copy-of  select ="$ShareITRecords/ShareIT[Observer = 1]"></xsl:copy-of>
        </xsl:variable>

        <div class="marginLeft15">
            <div class="labelGoalTitle paddingBottom10 paddingLeft5" style="border-bottom:1px solid gray;">
                My Team
            </div>
            <div>
                <div class="seperatorLine marginLeft30">Coach/Manager</div>
                <div id="div_{$GoalItemID}_MyTeam_Coaches">
                    <xsl:call-template name="ShareItListTemplate">
                        <xsl:with-param name="ShareITRecords" select="msxsl:node-set($CoachShareITRec)"></xsl:with-param>
                        <xsl:with-param name="GoalItemID" select="$GoalItemID"></xsl:with-param>
                        <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                        <xsl:with-param name="UserID" select="$UserID"></xsl:with-param>
                        <xsl:with-param name="Origin">
                            <xsl:text>CoachesShareIt</xsl:text>
                        </xsl:with-param>
                        <xsl:with-param name="PermissionID" select="$PermissionID"></xsl:with-param>
                        <xsl:with-param name="Permissions" select="$Permissions"></xsl:with-param>
                        <xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
                    </xsl:call-template>
                </div>
                <div id="div_AutoSuggest_{$GoalItemID}" class="marginLeft30">
                </div>
                <div class="seperatorLine marginLeft30">Participant</div>
                <div id="div_{$GoalItemID}_MyTeam_Participants">
                    <xsl:call-template name="ShareItListTemplate">
                        <xsl:with-param name="ShareITRecords" select="msxsl:node-set($ParticipantShareITRec)"></xsl:with-param>
                        <xsl:with-param name="GoalItemID" select="$GoalItemID"></xsl:with-param>
                        <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                        <xsl:with-param name="UserID" select="$UserID"></xsl:with-param>
                        <xsl:with-param name="Origin">
                            <xsl:text>ParticipantsShareIt</xsl:text>
                        </xsl:with-param>
                        <xsl:with-param name="PermissionID" select="$PermissionID"></xsl:with-param>
                        <xsl:with-param name="Permissions" select="$Permissions"></xsl:with-param>
                        <xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
                    </xsl:call-template>
                </div>
                <div class="seperatorLine marginLeft30">Observers</div>
                <div id="div_{$GoalItemID}_MyTeam_Observers">
                    <xsl:call-template name="ShareItListTemplate">
                        <xsl:with-param name="ShareITRecords" select="msxsl:node-set($ObserverShareITRec)"></xsl:with-param>
                        <xsl:with-param name="GoalItemID" select="$GoalItemID"></xsl:with-param>
                        <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                        <xsl:with-param name="UserID" select="$UserID"></xsl:with-param>
                        <xsl:with-param name="Origin">
                            <xsl:text>ObserversShareIt</xsl:text>
                        </xsl:with-param>
                        <xsl:with-param name="PermissionID" select="$PermissionID"></xsl:with-param>
                        <xsl:with-param name="Permissions" select="$Permissions"></xsl:with-param>
                        <xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
                    </xsl:call-template>
                </div>
            </div>
        </div>
    </xsl:template>

</xsl:stylesheet>
