﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href="FollowDiscussion.xslt"/>
    <xsl:include href="Comment.xslt" />
    <xsl:include href="RateITContent.xslt"/>

    <xsl:template match="/">
        <xsl:variable name="ItemID" select="normalize-space(CommentsRateIt/RateIt/ItemID)"/>
        <xsl:variable name="PublicationName" select="N/A"/>
        <xsl:variable name="Followed" select="CommentsRateIt/IsFollowingItem"/>
        <xsl:variable name="CommentCount" select="normalize-space(CommentsRateIt/CommentCount)"/>

        <xsl:variable name="HostName" select="normalize-space(CommentsRateIt/HostName)"/>

        

        <div id="divComments" class="padding10" align="left">
            <!--The "Follow It" Section-->
            <div id="divFollowCommunity_{$ItemID}" class="notesReply"
                         style="width: 87%; margin-top: 2px; margin-left: 30px; 
                                padding-top: 3px; padding-bottom: 3px; padding-right: 10px;" align="left">
              <xsl:call-template name="FollowDiscussion">
                <xsl:with-param name="Followed">
                  <xsl:choose>
                    <xsl:when test="$Followed = 'True'">
                      <xsl:number value ="1"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:number value ="0"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:with-param>
                <xsl:with-param name="DiscussionItemID" select="$ItemID"></xsl:with-param>
                <xsl:with-param name="DiscussionName" select="$PublicationName"></xsl:with-param>
              </xsl:call-template>
            </div>

            <!--Shows all the Comments by different users-->
            <div id="div_PublicationComments">
                <div id="divDisplayComments" align="left">
                    <xsl:for-each select="CommentsRateIt/Comment[position() &lt;=2]">
                        <xsl:call-template name="CommentsTemplate"></xsl:call-template>
                    </xsl:for-each>
                </div>
                <div id="divHiddenComments" style="display:none;" align="left">
                    <xsl:for-each select="CommentsRateIt/Comment[position() &gt;2]">
                        <xsl:call-template name="CommentsTemplate"></xsl:call-template>
                    </xsl:for-each>
                </div>
            </div>
            <xsl:if test ="$CommentCount &gt; 2">
            <div id="div_ShowComments" align="left" style="margin-top: 2px; margin-left: 30px; 
                     padding-left: 10px; padding-top: 3px; padding-bottom: 3px; width: 80%;">
                <a class="link" onclick='displayComments("divHiddenComments");'
                   onmouseover="this.style.textDecoration='underline';"
                   onmouseout="this.style.textDecoration='none';">
                    <xsl:if test="$CommentCount &gt; 2">
                        Show all&#xa0;<xsl:value-of select ="$CommentCount"/>&#xa0;Comments
                    </xsl:if>
                </a>
            </div>
            </xsl:if>
            <!--Shows the textbox to give comments-->
            <div id="div_RateIt_{normalize-space($ItemID)}_AddRateComments"
                 style="display: block; margin-top: 10px;  margin-bottom: 10px; padding-left: 30px; width: 89%;">
                <textarea id="txt_RateIt_{normalize-space($ItemID)}_Comments" rows="1" class="textAreaNotes"
                          onclick='return RateIt_AddComments(
                                                            "div_RateIt_{normalize-space($ItemID)}_AddComments",
                                                            "txt_RateIt_{normalize-space($ItemID)}_Comments"
                                                            );'
                          onblur='return RateIt_retainCommentsPrevState(
                                                            "div_RateIt_{normalize-space($ItemID)}_AddComments",
                                                            "txt_RateIt_{normalize-space($ItemID)}_Comments"
                                                            );'>Add your comment here...</textarea>
            </div>
            <div id="div_RateIt_{normalize-space($ItemID)}_AddComments" style="padding-left: 30px; display: none;">
                <input value="Submit" type="button" class="button"
                       onClick='rateIT_AddUserComment(
                                                             "div_PublicationComments",
                                                             "txt_RateIt_{normalize-space($ItemID)}_Comments",
                                                             "div_RateIt_{normalize-space($ItemID)}_AddComments",
                                                             "{normalize-space($ItemID)}"
                                                             );
                       discussion_Follow({$ItemID},"",3,"divFollowCommunity_{$ItemID}");'></input>
            </div>
        </div>

     
        
    </xsl:template>
</xsl:stylesheet>
