﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:variable name="User" select="Communities/UserName"/>
        <xsl:variable name="TemplateCount" select="count(Communities/Templates/Template)"/>
        <xsl:variable name="ContentCount" select="count(Communities/Contents/Content)"/>
        <xsl:variable name="PublicationCount" select="count(Communities/Publications/Publication)"/>
        <html>
            <head>
            </head>
            <body>
                <div id="divCommunityEmail_Container" style="margin-left:3%;z-index: 1; background-color: #FFFFFF;">
                    <div style="padding-top: 10px; margin-bottom: 10px;">
                        <div align="left" style="font-family: Calibri, Verdana, Arial;font-size: 13pt;
                                                  margin-bottom:10px;">
                            Hi&#xa0;<xsl:value-of select ="$User"/>,
                        </div>
                        <div style="margin-top:10px; margin-bottom:10px;">
                            <span align="left" style="font-family: Calibri, Verdana, Arial;font-size: 13pt;">
                                You are following:
                                 <font color="#17375E">
                                    <a href="/CommunityWizard.aspx?Ref=EM.Com">
                                        <u>
                                            <xsl:for-each select ="Communities/Items/ItemName">
                                                <xsl:if test ="position() != 1">,&#xa0;<xsl:value-of select ="Item"/>
                                                </xsl:if>
                                                <xsl:if test ="position() = 1"><xsl:value-of select ="Item"/>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </u>
                                    </a>
                                </font>
                            </span>
                        </div>
                    </div>
                    <xsl:if test="$PublicationCount &gt; 0">
                        <div style="margin-top: 10px; margin-bottom: 10px;">
                            <table cellpadding="3" border="0" cellspacing="3">
                                <tr>
                                    <td colspan="2">
                                        <span align="left" style="font-family: Calibri, Verdana, Arial;font-size: 13pt;">
                                            Here are the&#xa0;<xsl:value-of select ="$PublicationCount"/>&#xa0;most current posts made in the communities you follow:
                                        </span>
                                    </td>
                                </tr>
                                <xsl:for-each select ="Communities/Publications/Publication">
                                    <tr height="5"></tr>
                                    <tr style="padding-top:2px; padding-bottom:2px;">
                                        <td>
                                            <xsl:if test ="ImageURL != ''">
                                                <img  style="display:inline; margin-left: 0px; vertical-align: middle; width:100px;"
                                                src="{ImageURL}"></img>
                                            </xsl:if>
                                        </td>
                                        <td valign="top">
                                            <div style="font-family: Calibri, Verdana, Arial; font-size: 12pt;font-weight: bold;">
                                                <font color="#17375E">
                                                    <a href="/Publication.aspx?ID={normalize-space(ItemID)}&amp;Ref=EM.Com">
                                                        <u>
                                                            <xsl:value-of select="Title"/>
                                                        </u>
                                                    </a>
                                                </font>
                                            </div>
                                            <div style="text-align: justify; font-family: Calibri, Verdana, Arial; font-size: 11pt;">
                                                <xsl:value-of select="Summary"/>
                                            </div>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                            </table>
                        </div>
                    </xsl:if>
                    <xsl:if test="$TemplateCount &gt; 0">
                        <div style="margin-top: 10px; margin-bottom: 10px;">
                            <table cellpadding="3" border="0" cellspacing="3">
                                <tr>
                                    <td colspan="2">
                                        <span align="left" style="font-family: Calibri, Verdana, Arial;font-size: 13pt;">
                                            Here are the&#xa0;<xsl:value-of select ="$TemplateCount"/>&#xa0;most current templates added to the communities you follow:
                                        </span>
                                    </td>
                                </tr>
                                <xsl:for-each select ="Communities/Templates/Template">
                                    <tr height="5"></tr>
                                    <tr style="padding-top:2px; padding-bottom:2px;">
                                        <td>
                                            <xsl:if test ="TemplateImage != ''">
                                                <img  style="display:inline; margin-left: 0px; vertical-align: middle;width:100px;"
                                                src="{TemplateImage}"></img>
                                            </xsl:if>
                                        </td>
                                        <td valign="top">
                                            <div style="font-family: Calibri, Verdana, Arial; font-size: 12pt;font-weight: bold;">
                                                <font color="#17375E">
                                                    <a href="/{PromoteKey}?Ref=EM_Com">
                                                        <u>
                                                            <xsl:value-of select="Name"/>
                                                        </u>
                                                    </a>
                                                </font>
                                            </div>
                                            <div style="text-align: justify; font-family: Calibri, Verdana, Arial; font-size: 11pt;">
                                                <xsl:value-of select="Description"/>
                                            </div>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                            </table>
                        </div>
                    </xsl:if>
                    <xsl:if test="$ContentCount &gt; 0">
                        <div style="margin-top: 10px; margin-bottom: 10px;">
                            <table cellpadding="3" border="0" cellspacing="3">
                                <tr>
                                    <td colspan="2">
                                        <span align="left" style="font-family: Calibri, Verdana, Arial;font-size: 13pt;">
                                            Here are the&#xa0;<xsl:value-of select ="$ContentCount"/>&#xa0;most current articles and links added in the communities you follow:
                                        </span>
                                    </td>
                                </tr>
                                <xsl:for-each select ="Communities//Contents/Content">
                                    <tr height="5"></tr>
                                    <tr style="padding-top:2px; padding-bottom:2px;">
                                        <td>
                                            <xsl:if test ="ImageAttach != ''">
                                                <img  style="display:inline; margin-left: 0px; vertical-align: middle;width:100px;"
                                                src="{ImageAttach}"></img>
                                            </xsl:if>
                                        </td>
                                        <td valign="top">
                                            <div style="font-family: Calibri, Verdana, Arial; font-size: 12pt;font-weight: bold;">
                                                <font color="#17375E">
                                                    <a href="/Content.aspx?ID={normalize-space(ItemID)}&amp;Ref=EM.Com">
                                                        <u>
                                                            <xsl:value-of select="ContentName"/>
                                                        </u>
                                                    </a>
                                                </font>
                                            </div>
                                            <div style="text-align: justify; font-family: Calibri, Verdana, Arial; font-size: 11pt;">
                                                <xsl:value-of select="ContentMemo"/>
                                            </div>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                            </table>
                        </div>
                    </xsl:if>
                     <div style="padding-top: 10px; margin-bottom: 10px;">
                          <span style="font-family: Calibri, Verdana, Arial; font-size: 9pt;color: Gray">
                               <a href="/Settings.aspx">
                                    <u>Unsubscribe</u>
                               </a>&#xa0;or&#xa0;<a href="/Settings.aspx">
                                    <u>Change your Settings</u>
                               </a>
                          </span>
                     </div>
                </div>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>
