﻿<?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="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
        <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
        <xsl:variable name ="countNode" select ="count(Publications/Publication)"></xsl:variable>
        <xsl:variable name ="FaceBookSrc" select ="Publications/FaceBookSrc"></xsl:variable>
        <xsl:variable name ="TwitterSrc" select ="Publications/TwitterSrc"></xsl:variable>
        <xsl:variable name ="UserID" select ="Publications/UserID"></xsl:variable>
        <xsl:variable name ="TemplateURL" select ="Publications/TemplateURL"></xsl:variable>
        <xsl:variable name ="HostName" select ="normalize-space(Publications/HostName)"></xsl:variable>
        <xsl:variable name ="Mode" select ="Publications/Mode"></xsl:variable>
        <xsl:variable name ="PublicationCount" select ="Publications/PublicationCount"></xsl:variable>
        <xsl:variable name ="IsCommunityAdmin" select ="Publications/IsCommunityAdmin"></xsl:variable>
        <xsl:variable name="SocialSharePublishedYN">
            <xsl:choose>
                <xsl:when test="translate(Publications/Settings/Community/SocialSharePublishedYN, $smallcase, $uppercase) = 'FALSE'">
                    <xsl:number value="0"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:number value="1"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <!-- Dream It Start -->
        <div id="divDreamIt_Container">
            <!--<div>
                MasterPortalItemID = <xsl:value-of select="Publications/Settings/MasterPortalItemID"/>
        </div>-->
            <table class="tableMaster" border="0" cellspacing="5" cellpadding="5">
                <xsl:if test ="normalize-space($Mode) = 'Item' and normalize-space($PublicationCount) &gt; -1">
                    <tr>
                        <td colspan="2" style="text-align: center; vertical-align: middle;">
                            <span class="link">
                                <a href="http://{$HostName}/ListPublications.aspx" class="link">
                                    View All Publications
                                </a>
                            </span>
                            <span class="link" style="margin-left: 20px; margin-right: 20px;">
                                <a href="http://{$HostName}/ListCommunities.aspx" class="link">
                                    View All Communities
                                </a>
                            </span>
                            <span class="link">
                                <a href="http://{$HostName}/ListTemplates.aspx" class="link">
                                    View All Goal Templates
                                </a>
                            </span>
                        </td>
                    </tr>
                </xsl:if>

                <tr>
                    <td colspan="2">
                        <xsl:if test="not(Publications/Settings/MasterPortalItemID)">
                            <table class="tableMaster">
                                <tr>
                                    <td width="15">
                                        <a class="link" href="http://feeds.feedburner.com/Lifespace" title="Subscribe to my feed">
                                            <img src="{normalize-space($TemplateURL)}\web\images\RSSFeed.bmp"
                                                 style="border:0; display: none;" onload='setWidthAndHeightImage(this, "20");'/>
                                        </a>
                                    </td>
                                    <td>
                                        <a href="http://feeds.feedburner.com/Lifespace" title="Subscribe to my feed" style="text-decoration:none;">
                                            <span class="packageTitle">
                                                Publication Feeds
                                            </span>
                                        </a>
                                    </td>
                                </tr>
                            </table>
                        </xsl:if>
                    </td>
                </tr>

                <tr>
                    <td>
                        <xsl:if test ="normalize-space(Publication/Mode)='LifeSpaceUpdatesWe'">
                            <xsl:for-each select="Publications/Publication">

                                <xsl:variable name='TargetPubURL'>
                                    <xsl:text>http://</xsl:text>
                                    <xsl:value-of select='$HostName'/>
                                    <xsl:text>/</xsl:text>
                                    <xsl:choose>
                                        <xsl:when test='PromoteKey[text()] and string-length(PromoteKey) &gt; 0'>
                                            <xsl:value-of select='PromoteKey'/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:text>Publication.aspx?ID=</xsl:text>
                                            <xsl:value-of select='ItemID'/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>

                                <table class="tableMaster">
                                    <tr>
                                        <td align="center" width="100" style="padding-bottom:10px; padding-top:5px;">
                                            <div id="divDreamITImage">
                                                <xsl:if test ="normalize-space(ImageURL) != ''">
                                                    <a href="{$TargetPubURL}">
                                                        <img src="{ImageURL}" style="display:inline; margin-left: 0px; border: 0px; vertical-align: middle; display: none;"
                                                               onload='setWidthAndHeightImage(this,"80");'></img>
                                                    </a>
                                                </xsl:if>
                                            </div>
                                        </td>
                                        <td valign="top" align="left" style="text-align:left; padding-bottom:10px;">
                                            <xsl:if test="position() != $countNode">
                                                <div id="divPublication" style="vertical-align:top; padding-bottom: 20px;" class="seperatorLine">
                                                    <div id="divPublicationHeader">


                                                        <table cellspacing="0" cellpadding="0">
                                                            <tr>
                                                                <td class="verticallyMiddle">
                                                                    <span id="spanPublicationTitle" class="linkHeader">
                                                                        <b>
                                                                            <a href="{$TargetPubURL}">
                                                                                <xsl:value-of select="Title"/>
                                                                            </a>
                                                                        </b>
                                                                    </span>
                                                                    <xsl:if test="(PublicationLevel = 2 or PublicationLevel = 4) and Subtitle != ''">
                                                                        <span id="spanPublicationSubTitle" class="labelItalic labelHeader">
                                                                            (<xsl:value-of select="Subtitle"/>)
                                                                        </span>
                                                                    </xsl:if >
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <a id="linkFacebook"
                                                                           target="_blank" class="link"
                                                                           href="http://{normalize-space(../HostName)}/LifeSpacePromoter.aspx?Id={normalize-space(ItemID)}&amp;Ref=FB&amp;page=/desktopmodules/LifeSpacePages/Item.aspx">
                                                                            <img src="{normalize-space($TemplateURL)}web/images/facebook.png" alt="Follow us on Facebook!"
                                                                                width="16" height="16" hspace="3" border="0" align="absmiddle"/>
                                                                        </a>
                                                                    </xsl:if>
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <a id="linkTwitter"
                                                                           target="_blank" class="link"
                                                                           href="http://{normalize-space(../HostName)}/LifeSpacePromoter.aspx?Id={normalize-space(ItemID)}&amp;Ref=TW&amp;page=/desktopmodules/LifeSpacePages/Item.aspx">
                                                                            <img src="{normalize-space($TemplateURL)}web/images/twitter.png" alt="Follow us on Twitter!"
                                                                                width="16" height="16" hspace="3" border="0" align="absmiddle"/>
                                                                        </a>
                                                                    </xsl:if>
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <div class="g-plusone" data-size="small" data-count="false"
                                                                             data-href="{$TargetPubURL}&amp;REF=PLUS-U{normalize-space($UserID)}"></div>
                                                                    </xsl:if>
                                                                </td>
                                                            </tr>
                                                        </table>

                                                    </div>
                                                    <div id="divPublicationSummary">
                                                        <span id="spanPublicationSummary" class="label">
                                                            <xsl:value-of select="Summary" disable-output-escaping="yes"/>
                                                        </span>&#xa0;&#xa0;
                                                        <a id="spanPublicationSummaryMore" class="link"
                                                              href="{$TargetPubURL}">
                                                            (More...)
                                                        </a>
                                                    </div>
                                                </div>
                                            </xsl:if>
                                            <xsl:if test="position() = $countNode">
                                                <div id="divPublication">
                                                    <div id="divPublicationHeader">
                                                        <table cellspacing="0" cellpadding="0">
                                                            <tr>
                                                                <td class="verticallyMiddle">
                                                                    <span id="spanPublicationTitle" class="linkHeader">
                                                                        <b>
                                                                            <a href="{$TargetPubURL}">
                                                                                <xsl:value-of select="Title"/>
                                                                            </a>
                                                                        </b>
                                                                    </span>
                                                                    <xsl:if test="(PublicationLevel = 2 or PublicationLevel = 4) and Subtitle != ''">
                                                                        <span id="spanPublicationSubTitle" class="labelItalic labelHeader">
                                                                            (<xsl:value-of select="Subtitle"/>)
                                                                        </span>
                                                                    </xsl:if >

                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <a id="linkFacebook"
                                                              target="_blank" class="link"
                                                              href="http://{normalize-space(../HostName)}/LifeSpacePromoter.aspx?Id={normalize-space(ItemID)}&amp;Ref=FB&amp;page=/desktopmodules/LifeSpacePages/Item.aspx">
                                                                            <img src="{normalize-space($TemplateURL)}web/images/facebook.png" alt="Follow us on Facebook!"
                                                                                width="16" height="16" hspace="3" border="0" align="absmiddle"/>
                                                                        </a>
                                                                    </xsl:if>
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <a id="linkTwitter"
                                                               target="_blank" class="link"
                                                               href="http://{normalize-space(../HostName)}/LifeSpacePromoter.aspx?Id={normalize-space(ItemID)}&amp;Ref=TW&amp;page=/desktopmodules/LifeSpacePages/Item.aspx">
                                                                            <img src="{normalize-space($TemplateURL)}web/images/twitter.png" alt="Follow us on Twitter!"
                                                                                width="16" height="16" hspace="3" border="0" align="absmiddle"/>
                                                                        </a>
                                                                    </xsl:if>
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <div class="g-plusone" data-size="small" data-count="false"
                                                                 data-href="{$TargetPubURL}&amp;REF=PLUS-U{normalize-space($UserID)}"></div>
                                                                    </xsl:if>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>
                                                    <div id="divPublicationSummary">
                                                        <span id="spanPublicationSummary" class="label">
                                                            <xsl:value-of select="Summary" disable-output-escaping="yes"/>
                                                        </span>&#xa0;&#xa0;
                                                        <a id="spanPublicationSummaryMore" class="link"
                                                              href="{$TargetPubURL}">
                                                            (More...)
                                                        </a>
                                                    </div>
                                                    <div style="margin-top:20px; margin-bottom:10px;">
                                                    </div>
                                                </div>
                                            </xsl:if>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                        </td>
                                        <td>
                                            <div id="divPromotionLink">
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test ="normalize-space(Publication/Mode)!='LifeSpaceUpdatesWe'">
                            <xsl:for-each select="Publications/Publication">


                                <xsl:variable name='TargetPubURL'>
                                    <xsl:text>http://</xsl:text>
                                    <xsl:value-of select='$HostName'/>
                                    <xsl:text>/</xsl:text>
                                    <xsl:choose>
                                        <xsl:when test='PromoteKey[text()] and string-length(PromoteKey) &gt; 0'>
                                            <xsl:value-of select='PromoteKey'/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:text>Publication.aspx?ID=</xsl:text>
                                            <xsl:value-of select='ItemID'/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>

                                <table class="tableMaster">
                                    <tr>
                                        <td align="center" width="100" style="padding-bottom:10px; padding-top:5px;">
                                            <div id="divDreamITImage" style="margin-top:5px;" align="center">
                                                <xsl:if test ="normalize-space(ImageURL) != ''">
                                                    <a href="{$TargetPubURL}">
                                                        <img src="{ImageURL}" align="center" style=" border:0px; display: none;"
                                                               onload='setWidthAndHeightImage(this,"80");'></img>
                                                    </a>
                                                </xsl:if>
                                            </div>
                                        </td>
                                        <td valign="top" align="left" style="text-align:left; padding-bottom:10px;">
                                            <xsl:if test="position() != $countNode">
                                                <div id="divPublication" style="vertical-align:top; padding-bottom: 20px; margin-top:0px;">
                                                    <div id="divPublicationHeader">

                                                        <table cellspacing="0" cellpadding="0">
                                                            <tr>
                                                                <td class="verticallyMiddle">
                                                                    <span id="spanPublicationTitle" class="packageTitle">
                                                                        <b>
                                                                            <a href="{$TargetPubURL}"
                                                                               style="font-family: 'PT Sans', sans-serif;font-size: 13px;color: #4B4B4B;font-weight:700;text-decoration:none;">
                                                                                <xsl:value-of select="Title"/>
                                                                            </a>
                                                                        </b>
                                                                    </span>
                                                                    <xsl:if test="(PublicationLevel = 2 or PublicationLevel = 4) and Subtitle != ''">
                                                                        <span id="spanPublicationSubTitle" class="labelItalic publicationSubtitle">
                                                                            (<xsl:value-of select="Subtitle"/>)
                                                                        </span>
                                                                    </xsl:if >
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <a id="linkFacebook"
                                                                           target="_blank" class="link"
                                                                           href="http://{normalize-space(../HostName)}/LifeSpacePromoter.aspx?Id={normalize-space(ItemID)}&amp;Ref=FB&amp;page=/desktopmodules/LifeSpacePages/Item.aspx">
                                                                            <img src="{normalize-space($TemplateURL)}web/images/facebook.png" alt="Follow us on Facebook!"
                                                                                width="16" height="16" hspace="3" border="0" align="absmiddle"/>
                                                                        </a>
                                                                    </xsl:if>
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <a id="linkTwitter"
                                                                           target="_blank" class="link"
                                                                           href="http://{normalize-space(../HostName)}/LifeSpacePromoter.aspx?Id={normalize-space(ItemID)}&amp;Ref=TW&amp;page=/desktopmodules/LifeSpacePages/Item.aspx">
                                                                            <img src="{normalize-space($TemplateURL)}web/images/twitter.png" alt="Follow us on Twitter!"
                                                                                width="16" height="16" hspace="3" border="0" align="absmiddle"/>
                                                                        </a>
                                                                    </xsl:if>
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <div class="g-plusone" data-size="small" data-count="false"
                                                                             data-href="{$TargetPubURL}&amp;REF=PLUS-U{normalize-space($UserID)}"></div>
                                                                    </xsl:if>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>
                                                    <div id="divPublicationSummary">
                                                        <span id="spanPublicationSummary" class="publicationSummary">
                                                            <xsl:value-of select="Summary" disable-output-escaping="yes"/>
                                                        </span>&#xa0;&#xa0;
                                                        <a id="spanPublicationSummaryMore"
                                                           style="text-decoration:none;font-family: 'PT Sans', sans-serif;font-size: 13px;color: #4B4B4B;font-weight:700;"
                                                              href="{$TargetPubURL}">
                                                            (More...)
                                                        </a>
                                                    </div>
                                                </div>
                                            </xsl:if>
                                            <xsl:if test="position() = $countNode">
                                                <div id="divPublication">
                                                    <div id="divPublicationHeader">

                                                        <table cellspacing="0" cellpadding="0">
                                                            <tr>
                                                                <td class="verticallyMiddle">
                                                                    <span id="spanPublicationTitle" class="linkHeader">
                                                                        <a href="{$TargetPubURL}"
                                                                           style="text-decoration:none;font-family: 'PT Sans', sans-serif;font-size: 13px;color: #4B4B4B;font-weight:700;">
                                                                            <xsl:value-of select="Title"/>
                                                                        </a>
                                                                    </span>
                                                                    <xsl:if test="(PublicationLevel = 2 or PublicationLevel = 4) and Subtitle != ''">
                                                                        <span id="spanPublicationSubTitle" class="labelItalic publicationSubtitle">
                                                                            (<xsl:value-of select="Subtitle"/>)
                                                                        </span>
                                                                    </xsl:if >
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <a id="linkFacebook"
                                                                           target="_blank" class="link"
                                                                           href="http://{normalize-space(../HostName)}/LifeSpacePromoter.aspx?Id={normalize-space(ItemID)}&amp;Ref=FB&amp;page=/desktopmodules/LifeSpacePages/Item.aspx">
                                                                            <img src="{normalize-space($TemplateURL)}web/images/facebook.png" alt="Follow us on Facebook!"
                                                                                width="16" height="16" hspace="3" border="0" align="absmiddle"/>
                                                                        </a>
                                                                    </xsl:if>
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <a id="linkTwitter"
                                                                           target="_blank" class="link"
                                                                           href="http://{normalize-space(../HostName)}/LifeSpacePromoter.aspx?Id={normalize-space(ItemID)}&amp;Ref=TW&amp;page=/desktopmodules/LifeSpacePages/Item.aspx">
                                                                            <img src="{normalize-space($TemplateURL)}web/images/twitter.png" alt="Follow us on Twitter!"
                                                                                width="16" height="16" hspace="3" border="0" align="absmiddle"/>
                                                                        </a>
                                                                    </xsl:if>
                                                                </td>
                                                                <td class="verticallyMiddle">
                                                                    <xsl:if test="$SocialSharePublishedYN = 1">
                                                                        <div class="g-plusone" data-size="small" data-count="false"
                                                                             data-href="{$TargetPubURL}&amp;REF=PLUS-U{normalize-space($UserID)}"></div>
                                                                    </xsl:if>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>
                                                    <div id="divPublicationSummary">
                                                        <span id="spanPublicationSummary" class="label">
                                                            <xsl:value-of select="Summary" disable-output-escaping="yes"/>
                                                        </span>&#xa0;&#xa0;
                                                        <a id="spanPublicationSummaryMore" style="text-decoration:none;font-family: 'PT Sans', sans-serif;font-size: 13px;color: #4B4B4B;font-weight:700;"
                                                              href="{$TargetPubURL}">
                                                            (More...)
                                                        </a>
                                                    </div>
                                                </div>
                                            </xsl:if>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                        </td>
                                        <td>
                                            <div id="divPromotionLink">
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </xsl:for-each>
                        </xsl:if>
                    </td>
                    <!--<td align="left">
                        <div style="padding-bottom: 10px; font-weight: bold; text-align: center;">
                            <xsl:if test="Publications/AdHtml != ''">
                                LS Recommends:
                            </xsl:if>
                        </div>
                    </td>-->
                </tr>
            </table>
        </div>
        <!-- Dream It End -->
    </xsl:template>
</xsl:stylesheet>
