﻿<?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="../Version_2_0/PopUpHeader.xslt"/>
    <xsl:import href="../GenericTemplates/StringReplace.xslt"/>
    <xsl:include href="../Version_2_0/CompleteGoal.xslt"/>

    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="/">
        <xsl:variable name="Timestamp" select="AjaxRequest/TimeStamp"></xsl:variable>
        <xsl:variable name="GoalName" select="AjaxRequest/Items/Item/Item"></xsl:variable>

        <xsl:call-template name="GoalGetSocial">
            <xsl:with-param name="GoalID" select="AjaxRequest/Params/GoalItemID"></xsl:with-param>
            <xsl:with-param name="TemplateURL" select="AjaxRequest/TemplateURL"></xsl:with-param>
            <xsl:with-param name="HostName" select="AjaxRequest/HostName"></xsl:with-param>
            <xsl:with-param name="TimeStamp" select="$Timestamp"></xsl:with-param>
            <xsl:with-param name="GoalName" select="$GoalName"></xsl:with-param>
        </xsl:call-template>

    </xsl:template>

    <xsl:template name="GoalGetSocial">
        <xsl:param name="GoalID" select="'N/A'"></xsl:param>
        <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
        <xsl:param name="HostName" select="'N/A'"></xsl:param>
        <xsl:param name="TimeStamp" select="'N/A'"></xsl:param>
        <xsl:param name="GoalName" select="'N/A'"></xsl:param>
        <xsl:param name="Origin" select="'N/A'"></xsl:param>
        <xsl:param name="LoggedInUserID" select="'N/A'"></xsl:param>

        <xsl:variable name="GoalOpenPage">
            <xsl:choose>
                <xsl:when test="$Origin = 'ChallengeGoal'">
                    <xsl:text>Challenge</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>Goal</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="Mode">
            <xsl:choose>
                <xsl:when test="$Origin = 'ChallengeGoal'">
                    <xsl:text>Challenge</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>Template</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="InviteHeaderText">
            <xsl:choose>
                <xsl:when test="$Origin = 'ChallengeGoal'">
                    <xsl:text>E-mail friends to join this challenge</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>Email friends to start their own goal.</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="GetSocialHeaderText">
            <xsl:choose>
                <xsl:when test="$Origin = 'ChallengeGoal'">
                    <xsl:text>Get social and share this challenge</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>Get Social and share this goal.</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="CorrectedGoalName">
            <xsl:call-template name="replaceCharsInString">
                <xsl:with-param name="stringIn" select="$GoalName"></xsl:with-param>
                <xsl:with-param name="charsIn">
                    <xsl:text>'</xsl:text>
                </xsl:with-param>
                <xsl:with-param name="charsOut">
                    <xsl:text>\'</xsl:text>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:variable>

        <div id="divGoalGetSocial_{$GoalID}" class="popUpBackground">

            <xsl:if test="$Origin != 'ChallengeGoal'">
                <xsl:call-template name="PopUpHeader">
                    <xsl:with-param name="ItemID" select="$GoalID"></xsl:with-param>
                    <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                    <xsl:with-param name="HeaderText">
                        <xsl:text>Share this Goal</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:if>

            <div id="divCompleteGoalContent_{$GoalID}" class="paddingBottom10">
                <div id="divShareWithFriends_{$GoalID}" class="padding15" style="border-bottom:1px solid gray;">
                    <table cellpadding="4" class="tableMaster">
                        <tr>
                            <td>
                                <span class="labelGoalTopicsText">
                                    <xsl:value-of select="$InviteHeaderText"/>
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input value="ENTER FRIENDS EMAILS" class="EmailInviteText" type="text" id="txt_Email_{$GoalID}" style="width:99%;height:22px;"
									   onclick='SetTextAreaValue("txt_Email_{$GoalID}", "ENTER FRIENDS EMAILS", "focus");'
									   onblur='SetTextAreaValue("txt_Email_{$GoalID}", "ENTER FRIENDS EMAILS", "blur");'></input>
                            </td>
                        </tr>
                      <!--<xsl:if test="$Origin = 'ChallengeGoal'">
                        <tr>
                          <td>
                            <a href="#" onclick="showPlaxoABChooser('txt_Email_{$GoalID}', '/plaxo_cb.htm'); return false">
                              <img src="http://www.plaxo.com/images/abc/buttons/add_button.gif" alt="Add from my address book" style="border:0; margin-bottom:10px;"/>
                            </a>
                          </td>
                        </tr>
                      </xsl:if>-->
                        <tr>
                            <td>
                                <textarea id="emailContent" style="width:377px;" class="notificationTypeText" rows="4"
                                              onfocus="removeWhiteSpace('emailContent');
                                                   SetTextAreaValue('emailContent','ADD A MESSAGE','focus');"
                                              onBlur='SetTextAreaValue("emailContent","ADD A MESSAGE","blur")'>
                                    <xsl:text>ADD A MESSAGE</xsl:text>
                                </textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="textRight" style="padding-top:15px;padding-bottom:10px;">
                                <span class="padding10 onMouseOver divBrowseGradient spanBrowseGradientTextGray"
									  onmouseover="document.getElementById('img_SendInvite').src='{$TemplateURL}Web/Images/Ver_2_0/icon_send_over.png';"
									  onmouseout="document.getElementById('img_SendInvite').src='{$TemplateURL}Web/Images/Ver_2_0/icon_send.png';"
                                      onclick="Email_InviteUsers_Ver_2_0('txt_Email_{$GoalID}', 'emailContent', 
                                                                {$GoalID},'{$Mode}','{$CorrectedGoalName}','');">
                                    <img id="img_SendInvite" class="marginRight5" src="{$TemplateURL}Web/Images/Ver_2_0/icon_send.png" align="absmiddle"></img>
                                    <span id="span_SendInvite" class="capitalFont">Send Invite</span>
                                </span>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="labelGoalTopicsText marginTop15 marginLeft20">
                    <xsl:value-of select="$GetSocialHeaderText"/>
                </div>
                <div id="divShareSocialMedia_{$GoalID}" class="padding10" style="border-bottom:1px solid gray;">
                    <xsl:call-template name="ShareSocialMedia">
                        <xsl:with-param name="GoalID" select="$GoalID"></xsl:with-param>
                        <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                        <xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
                        <xsl:with-param name="LoggedInUserID" select="$LoggedInUserID"></xsl:with-param>
                        <xsl:with-param name="Origin" select="$Origin"></xsl:with-param>
                    </xsl:call-template>
                </div>
                <div class="padding15">
                    <div class="labelGoalTopicsText padding5">
                        Copy and Paste
                    </div>

                    <input id="text_GoalURL_{$GoalID}" type="text" class="copyPasteText onMouseOver" style="width:457px;height:25px;"
                                   onClick="SelectAll('text_GoalURL_{$GoalID}');"
                                   value="http://{$HostName}/{$GoalOpenPage}.aspx?ID={$GoalID}"></input>

                    <xsl:if test="$Origin != 'ChallengeGoal'">
                        <div class="textRight paddingRight10">
                            <span class="padding10 onMouseOver divBrowseGradient spanBrowseGradientTextGray" onclick="closePopupWhiteLayerContainer();"
                                  onmouseover="document.getElementById('img_Cancel').src='{$TemplateURL}Web/Images/Ver_2_0/BT_x_hover.png';"
                                  onmouseout="document.getElementById('img_Cancel').src='{$TemplateURL}Web/Images/Ver_2_0/BT_x.png';">
                                <img id="img_Cancel" class="marginRight5" src="{$TemplateURL}Web/Images/Ver_2_0/BT_x.png" align="absmiddle"></img>
                                <span id="span_Cancel" class="capitalFont">CANCEL</span>
                            </span>
                        </div>
                    </xsl:if>
                </div>
            </div>
        </div>

    </xsl:template>

    

</xsl:stylesheet>

