﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <div id="div_EmailDigest">
            <xsl:variable name ="CheckBoxIds">
                <xsl:for-each select="EmailDigest/Days/Day">
                    <xsl:choose>
                        <xsl:when test ="position() != count(../Day)">
                            <xsl:text>'div_EmailDigest_WeekDays_</xsl:text><xsl:value-of select="normalize-space(Name)"/>'<xsl:text>,</xsl:text>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text>'div_EmailDigest_WeekDays_</xsl:text><xsl:value-of select="normalize-space(Name)"/>'
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>
            </xsl:variable>

            <xsl:variable name="DailyDigestDisplay">
                <xsl:choose>
                    <xsl:when test="normalize-space(EmailDigest/Digest) &gt; 0">
                        <xsl:text>display: block;</xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text>display: none;</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <div id="div_EmailDigest_Close" style="margin-top:5px; margin-right:5px; text-align:right; display: none;">
                <span class="link" onclick="return CloseItemBox('div_EmailDigest','-99')">[ X ]</span>
            </div>
            <div>
                <!--<span class="labelHeader">LifeSpace Daily: To receive an e-mail summary of everything going on in your personal LifeSpace, please select which days you would like to receive this e-mail:</span>-->
                <span class="labelHeader">LifeSpace can send you a daily summary e-mail when there is new items and activity in your goals and communities.  You can change the frequency of these summary e-mails below:</span>
            </div>
            &#xa0;
            <div id="div_ItemsDueToday_Choices" style="padding-bottom:5px;">
                <div>
                    <span class="labelBold">Items Due Today:</span>
                    <xsl:choose>
                        <xsl:when test="normalize-space(EmailDigest/ItemsDueTodayEmail) &gt; 0">
                            <input id="div_ItemsDueToday_Choices_Daily" type="radio" name="IDChoices" value="daily" class="label" checked="true"
                                   onClick="return saveUsersItemsEmailSettings('div_ItemsDueToday_Choices_Daily','9')"/> On
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="div_ItemsDueToday_Choices_Daily" type="radio" name="IDChoices" value="daily" class="label"
                                   onClick="return saveUsersItemsEmailSettings('div_ItemsDueToday_Choices_Daily','9')"/> On
                        </xsl:otherwise>
                    </xsl:choose>

                    <xsl:choose>
                        <xsl:when test="normalize-space(EmailDigest/ItemsDueTodayEmail) &lt;= 0">
                            <input id="div_ItemsDueToday_Choices_Never" type="radio" name="IDChoices" value="never" class="label" checked="true"
                                  onClick="return saveUsersItemsEmailSettings('div_ItemsDueToday_Choices_Daily','9')"/> Off
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="div_ItemsDueToday_Choices_Never" type="radio" name="IDChoices" value="never" class="label"
                                   onClick="return saveUsersItemsEmailSettings('div_ItemsDueToday_Choices_Daily','9')"/> Off
                        </xsl:otherwise>
                    </xsl:choose>
                </div>
                <div>
                    <span class="label">
                        * Note: E-mail only sent when items are due
                    </span>
                </div>
            </div>

            <div id="div_WhatsNewInCommunity_Choices" style="padding-bottom:5px;">
                <div>
                    <span class="labelBold">What's New in the Communities I Follow:</span>
                    <xsl:choose>
                        <xsl:when test="normalize-space(EmailDigest/WhatsNewCommunitiesEmail) &gt; 0">
                            <input id="div_WhatsNewInCommunity_Choices_Daily" type="radio" name="WNCChoices" value="daily" class="label" checked="true"
                                   onClick="return saveUsersItemsEmailSettings('div_WhatsNewInCommunity_Choices_Daily','10')"/> On
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="div_WhatsNewInCommunity_Choices_Daily" type="radio" name="WNCChoices" value="daily" class="label"
                                   onClick="return saveUsersItemsEmailSettings('div_WhatsNewInCommunity_Choices_Daily','10')"/> On
                        </xsl:otherwise>
                    </xsl:choose>

                    <xsl:choose>
                        <xsl:when test="normalize-space(EmailDigest/WhatsNewCommunitiesEmail) &lt;= 0">
                            <input id="div_WhatsNewInCommunity_Choices_Never" type="radio" name="WNCChoices" value="never" class="label" checked="true"
                                   onClick="return saveUsersItemsEmailSettings('div_WhatsNewInCommunity_Choices_Daily','10')"/> Off
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="div_WhatsNewInCommunity_Choices_Never" type="radio" name="WNCChoices" value="never" class="label"
                                   onClick="return saveUsersItemsEmailSettings('div_WhatsNewInCommunity_Choices_Daily','10')"/> Off
                        </xsl:otherwise>
                    </xsl:choose>
                </div>
                <div>
                    <span class="label">
                        * Schedule: Finance Community Updates on Mondays, Fitness on Wednesdays and Family, Fun and Faith on Fridays</span>                    
                   
                </div>
                <div>
                    <span class="label">
                        * Note: E-mail will only be sent if you are following the specific communities
                    </span>
                </div>
            </div>

            <!--<div id="div_EmailDigest_Choices" style="padding-bottom: 5px;">
                <span class="labelBold">Weekly Goal Summary of All My Active Goals:  </span>
                <xsl:choose>
                    <xsl:when test="normalize-space(EmailDigest/Digest) &gt; 0">
                        <input id="div_EmailDigest_Choices_Daily" type="radio" name="EDChoices" value="daily" class="label" checked="true"
                               onclick="return flipEmailDigestChoices(
                                                                'div_EmailDigest_Choices_Daily',
                                                                'div_EmailDigest_Choices_Monthly',
                                                                'div_EmailDigest_Choices_Never',
                                                                'div_EmailDigest_WeekDays', {normalize-space($CheckBoxIds)});" /> On
                    </xsl:when>
                    <xsl:otherwise>
                        <input id="div_EmailDigest_Choices_Daily" type="radio" name="EDChoices" value="daily" class="label"
                               onclick="return flipEmailDigestChoices(
                                                                'div_EmailDigest_Choices_Daily',
                                                                'div_EmailDigest_Choices_Monthly',
                                                                'div_EmailDigest_Choices_Never',
                                                                'div_EmailDigest_WeekDays', {normalize-space($CheckBoxIds)});" /> On
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:choose>
                    <xsl:when test="normalize-space(EmailDigest/Digest) = 0">
                        <input id="div_EmailDigest_Choices_Monthly" type="radio" name="EDChoices" value="monthly" class="label" checked="true"
                               style="display: none;"
                               onclick="return flipEmailDigestChoices(
                                                                'div_EmailDigest_Choices_Daily',
                                                                'div_EmailDigest_Choices_Monthly',
                                                                'div_EmailDigest_Choices_Never',
                                                                'div_EmailDigest_WeekDays', {normalize-space($CheckBoxIds)});"/>
                        --><!--Monthly--><!--
                    </xsl:when>
                    <xsl:otherwise>
                        <input id="div_EmailDigest_Choices_Monthly" type="radio" name="EDChoices" value="monthly" class="label"
                               style="display: none;"
                               onclick="return flipEmailDigestChoices(
                                                                'div_EmailDigest_Choices_Daily',
                                                                'div_EmailDigest_Choices_Monthly',
                                                                'div_EmailDigest_Choices_Never',
                                                                'div_EmailDigest_WeekDays', {normalize-space($CheckBoxIds)});"/>
                        --><!--Monthly--><!--
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:choose>
                    <xsl:when test="normalize-space(EmailDigest/Digest) = '' ">
                        <input id="div_EmailDigest_Choices_Never" type="radio" name="EDChoices" value="never" class="label" checked="true"
                               onclick="return flipEmailDigestChoices(
                                                                'div_EmailDigest_Choices_Daily',
                                                                'div_EmailDigest_Choices_Monthly',
                                                                'div_EmailDigest_Choices_Never',
                                                                'div_EmailDigest_WeekDays', {normalize-space($CheckBoxIds)});"/> Off
                    </xsl:when>
                    <xsl:otherwise>
                        <input id="div_EmailDigest_Choices_Never" type="radio" name="EDChoices" value="never" class="label"
                               onclick="return flipEmailDigestChoices(
                                                                'div_EmailDigest_Choices_Daily',
                                                                'div_EmailDigest_Choices_Monthly',
                                                                'div_EmailDigest_Choices_Never',
                                                                'div_EmailDigest_WeekDays', {normalize-space($CheckBoxIds)});"/> Off
                    </xsl:otherwise>
                </xsl:choose>
            </div>

            <div id="div_EmailDigest_WeekDays" style="{normalize-space($DailyDigestDisplay)}; padding-bottom: 10px; padding-top: 5px;">
                <xsl:for-each select="EmailDigest/Days/Day">
                    <xsl:choose>
                        <xsl:when test="normalize-space(Value) = 'true'">
                            <input id="div_EmailDigest_WeekDays_{normalize-space(Name)}"
                                   type="checkbox" name="days" value="{normalize-space(Name)}" class="label" checked="true"
                                   onclick="return GetEmailDailyDigestDay({normalize-space($CheckBoxIds)});" />
                            <xsl:value-of select="normalize-space(Name)"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="div_EmailDigest_WeekDays_{normalize-space(Name)}"
                                   type="checkbox" name="days" value="{normalize-space(Name)}" class="label"
                                   onclick="return GetEmailDailyDigestDay({normalize-space($CheckBoxIds)});" />
                            <xsl:value-of select="normalize-space(Name)"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>
            </div>-->
        </div>
    </xsl:template>
</xsl:stylesheet>