﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template name="DiscussionControls">
        <xsl:param name="IsCommunityAdmin" select="'N/A'"></xsl:param>
        <xsl:param name="Origin" select="'N/A'"></xsl:param>
        <xsl:param name="ItemID" select="'N/A'"></xsl:param>
        <xsl:param name="ExcludeDiscussionItemID" select="'N/A'"></xsl:param>
        <xsl:param name="ParentType" select="'N/A'"></xsl:param>
        <xsl:param name="PrimaryItemID" select="'N/A'"></xsl:param>
        <xsl:param name="SourceItemTypeID" select="'N/A'"></xsl:param>
        <xsl:param name="DiscussionCount" select="'N/A'"></xsl:param>
        <xsl:param name="IsAdmin" select="'N/A'"></xsl:param>
        <xsl:param name="RoleName" select="'N/A'"></xsl:param>

        <xsl:variable name="displayStyle">
            <xsl:choose>
                <xsl:when test="$DiscussionCount &gt; 2">
                    <xsl:text>display: inline;</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>display:none</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <div align="center">
            <xsl:choose>
                <xsl:when test="$Origin = 'ViewAllDiscussionAsync'">
                    <xsl:choose>
                        <xsl:when test="$ParentType ='17'">
                            <span id="span_ViewAllDiscussions" class="link labelBold" style="{$displayStyle}"
                                  onclick="viewAllDiscussionAsync('{$PrimaryItemID}', '{$ExcludeDiscussionItemID}', 'divListDiscussions_Data');"
                                  onmouseover="this.style.textDecoration='underline';"
                                  onmouseout="this.style.textDecoration='none';">View All Discussions</span>
                        </xsl:when>
                        <xsl:otherwise>
                            <span id="span_ViewAllDiscussions" class="link labelBold" style="{$displayStyle}"
                                  onclick="viewAllDiscussionAsync('{$ItemID}', '{$ExcludeDiscussionItemID}', 'divListDiscussions_Data');"
                                  onmouseover="this.style.textDecoration='underline';"
                                  onmouseout="this.style.textDecoration='none';">View All Discussions</span>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:when>
                <xsl:otherwise>
                    <span id="span_ViewAllDiscussions" class="link labelBold" style="{$displayStyle}"
                          onclick="makeAllDiscussionsVisible();"
                          onmouseover="this.style.textDecoration='underline';"
                          onmouseout="this.style.textDecoration='none';">View All Discussions</span>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="$IsCommunityAdmin = 'True' 
                    or $ParentType = '5' or $ParentType = '17'
                    or $SourceItemTypeID = '5' or $SourceItemTypeID = '17' 
                    or $IsAdmin = 1 
                    or $RoleName/Role[RoleName = 'Brand Admin']">
                <span class="link labelBold" style="margin-left: 10px; margin-right: 10px;"
                    onClick="return flipDiscussionBox('divListDiscussions', 'divAddDiscussions');"
                    onmouseover="this.style.textDecoration='underline';"
                    onmouseout="this.style.textDecoration='none';">Start a Discussion</span>
            </xsl:if>
        </div>
    </xsl:template>
</xsl:stylesheet>
