﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href="WizardButtons.xslt"/>

    <xsl:template match="/">
        <xsl:variable name="TemplatePathURL" select="normalize-space(LifeSpaces/TemplateURL)" />
        <xsl:variable name="HostName" select="normalize-space(LifeSpaces/HostName)" />

        <div id="divCommunityWizardLayout" style="width: 100%;">
            <!--<input id="communityWizardXML" type="hidden" value="&lt;CommunityWizard&gt;&lt;/CommunityWizard&gt;" ></input>-->

            <xsl:variable name="communityXMLInitialValue">
                &lt;CommunityWizard&gt;
                <xsl:for-each select="LifeSpaces/LifeSpace">
                    <xsl:for-each select="Communities/Community">
                        <xsl:if test="VolumeLevel = '3'">
                            &lt;Community&gt;
                            &lt;LifeSpaceID&gt;
                            <xsl:value-of select="../../ItemID"/>
                            &lt;/LifeSpaceID&gt;
                            &lt;CommunityID&gt;
                            <xsl:value-of select="ItemID"/>
                            &lt;/CommunityID&gt;
                            &lt;/Community&gt;
                        </xsl:if>
                    </xsl:for-each>
                </xsl:for-each>
                &lt;/CommunityWizard&gt;
            </xsl:variable>
            <input id="communityWizardXML" type="hidden" value="{$communityXMLInitialValue}" ></input>

            <div id="divGetStartedButtons" style="margin-top: 10px; margin-bottom: 10px;">
                <xsl:call-template name="WizardButtons">
                    <xsl:with-param name="TemplatePathURL" select="$TemplatePathURL"></xsl:with-param>
                    <xsl:with-param name="Source" >
                        <xsl:text>communitywizard</xsl:text>
                    </xsl:with-param>
                    <xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
                </xsl:call-template>
            </div>
            <div style="color: #376092; margin-top: 20px; margin-bottom: 10px;">
                <table class="tableMaster" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td align="top">
                            <span class="labelSize14">Step 3 of 4 - Communities To Follow.</span>
                        </td>
                        <td align="top" valign="top" rowspan="2">
                            <img src="{$TemplatePathURL}Web/Images/AdPerson_Left.jpg" title="AdPerson" BORDER="0"></img>
                        </td>
                    </tr>
                    <tr>
                        <td align="top">
                            <span class="labelSize13">
                                "Great work.  Now lets find some communities to follow.
                                By doing this, you will stay informed when the coaches are
                                discussing topics that are relevant to your goals and
                                projects.  Based on your action plan, I found some
                                communities that should be perfect for you.  Please check
                                off all communities you would like to follow. "
                            </span>
                        </td>
                    </tr>
                </table>
            </div>
            <div width="100%">
                <span class="labelSize11" style="color: black;">
                    Select Communities To Follow:
                </span>

                <div width="100%">
                    <table class="tableMaster">
                        <xsl:for-each select="LifeSpaces/LifeSpace">
                            <!--[not(following::LifeSpace/Item = 'LifeSpace LLC')]-->
                            <xsl:if test ="position() mod 2 = 1">
                                <tr>
                                    <td  width="50%">
                                        <xsl:call-template name="MyPlanCommunities">
                                            <xsl:with-param name="TemplatePathURL" select="normalize-space($TemplatePathURL)"></xsl:with-param>
                                            <xsl:with-param name="HostName" select="normalize-space($HostName)"></xsl:with-param>
                                            <xsl:with-param name="Item" select="normalize-space(Item)"></xsl:with-param>
                                            <xsl:with-param name="ItemID" select="normalize-space(ItemID)"></xsl:with-param>
                                            <xsl:with-param name="Communities" select="Communities/."></xsl:with-param>
                                        </xsl:call-template>
                                    </td>
                                    <td  width="50%">
                                        <xsl:call-template name="MyPlanCommunities">
                                            <xsl:with-param name="TemplatePathURL" select="normalize-space($TemplatePathURL)"></xsl:with-param>
                                            <xsl:with-param name="HostName" select="normalize-space($HostName)"></xsl:with-param>
                                            <xsl:with-param name="Item" select="normalize-space(following-sibling::LifeSpace[1]/Item)"></xsl:with-param>
                                            <xsl:with-param name="ItemID" select="normalize-space(following-sibling::LifeSpace[1]/ItemID)"></xsl:with-param>
                                            <xsl:with-param name="Communities" select="following-sibling::LifeSpace[1]/Communities/."></xsl:with-param>
                                        </xsl:call-template>
                                    </td>
                                </tr>
                            </xsl:if>
                        </xsl:for-each>
                    </table>
                </div>
            </div>
            <div align="right">
                <a href="http://{$HostName}/Social.aspx">
                    <img src="{$TemplatePathURL}Web/Images/BtnContinue.png" title="ContinueButton"
                         style="cursor: pointer;border: 0px;"
                         onclick=""></img>
                </a>
            </div>
        </div>
    </xsl:template>


    <xsl:template name="MyPlanCommunities">
        <xsl:param name="TemplatePathURL" select="'N/A'" />
        <xsl:param name="HostName" select="'N/A'" />
        <xsl:param name="Item" select="'N/A'"></xsl:param>
        <xsl:param name="ItemID" select="'N/A'"/>
        <xsl:param name="Communities" select="'N/A'"></xsl:param>
        <xsl:if test="$ItemID &gt; 0">
            <table class="tableMaster">
                <tr>
                    <td width="70px">
                        <xsl:choose>
                            <xsl:when test="$ItemID &gt; 6">
                                <img src="{$TemplatePathURL}Web/Images/LifeSpace LLC.jpg"
                                     width="70px" height="90px" ></img>
                            </xsl:when>
                            <xsl:otherwise>
                                <img src="{$TemplatePathURL}Web/Images/{$Item}.jpg"
                                     width="70px" height="90px" ></img>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                    <td>
                        <span class="labelSize11" style="color: black;">
                            <xsl:value-of select="$Item"/>
                        </span>
                        <div>
                            <table class="tableMaster">
                                <xsl:for-each select="$Communities/Community">
                                    <!--<xsl:if test="position()&lt;=5">-->
                                    <tr>
                                        <td width="20px">
                                            <xsl:choose>
                                                <xsl:when test="VolumeLevel = '3'">
                                                    <input id="chk_LifeSpace_Community_{ItemID}" type="checkbox" name="cbCommunity"
                                                            onclick="UpdateNotificationVolume(this, '{ItemID}','');"
                                                           checked="true"></input>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <input id="chk_LifeSpace_Community_{ItemID}" type="checkbox" name="cbCommunity"
                                                onclick="UpdateNotificationVolume(this, '{ItemID}','');"></input>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </td>
                                        <td>
                                            <span class="labelSize10">
                                                <a href="http://{$HostName}/Community.aspx?ID={ItemID}" target="_blank">
                                                    <xsl:value-of select="Item"/>
                                                </a>
                                            </span>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                            </table>
                        </div>
                    </td>
                </tr>
            </table>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>
