﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    <xsl:template name="BoxLayout">
        <xsl:param name="Title_TopLeft" select="'N/A'"/>
        <xsl:param name="Title_TopLeftStyle" select="'N/A'"/>
        <xsl:param name="Title_TopLeft_Link" select="'N/A'"/>
        <xsl:param name="Title_TopRight" select="'N/A'"/>
        <xsl:param name="Title_TopRight_Link" select="'N/A'"/>
        <xsl:param name="Content_LeftMargin" select="N/A"/>

        <xsl:param name="Content" select="'N/A'"/>
        <xsl:param name ="ShowCrossButton" select="'N/A'"/>
        <xsl:param name ="ShowCrossButtonFunction" select="'N/A'"/>

        <xsl:param name ="IdPrefix" select ="'div_Item'"/>
        <xsl:param name ="HeaderLinks" select="'N/A'"/>
        <xsl:param name ="TitleBackround" select="'N/A'"/>

        <div style="width:100%;" class="borderStanderd brandHeaderBorder">
            <table cellpadding="0" cellspacing="0" border="0" class="tableMaster">
                <tr>
                    <td>
                        <table cellpadding="0" cellspacing="0" border="0" class="tableMaster">
                            <tr>
                                <td align="left" valign="top" width="150">
                                    <xsl:if test ="normalize-space($Title_TopLeftStyle) = 'N/A' or 
                                        normalize-space($Title_TopLeftStyle) = ''">
                                        <xsl:choose>
                                            <xsl:when test ="$TitleBackround != ''">
                                                <div class="overlapLeft selectedTabBackColor selectedTabForColor selectedTabBorderColor" onClick='{normalize-space($Title_TopLeft_Link)}'
                                                     style="display: table; background-color: {normalize-space($TitleBackround)}">
                                                    <span class="labelBoxHeader overlapLeftText">
                                                        <xsl:value-of select="normalize-space($Title_TopLeft)"/>
                                                    </span>
                                                </div>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <div class="overlapLeft selectedTabBackColor selectedTabForColor selectedTabBorderColor" style="display: table;"
                                                     onClick='{normalize-space($Title_TopLeft_Link)}'>
                                                    <span class="labelHeader overlapLeftText labelSize11 selectedTabForColor">
                                                        <xsl:value-of select="normalize-space($Title_TopLeft)"/>
                                                    </span>
                                                </div>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:if>
                                    <xsl:if test ="normalize-space($Title_TopLeftStyle) != 'N/A' and 
                                        normalize-space($Title_TopLeftStyle) != ''">
                                        <div class="{normalize-space($Title_TopLeftStyle)} link"
                                             onClick='{normalize-space($Title_TopLeft_Link)}'>
                                            <span class="labelHeader">
                                                <xsl:value-of select="normalize-space($Title_TopLeft)"
                                                              disable-output-escaping ="yes"/>
                                            </span>
                                        </div>
                                    </xsl:if>
                                </td>
                                <td align="center" style="text-align: center;">
                                    <xsl:if test ="normalize-space($HeaderLinks) != 'N/A' and count(msxsl:node-set($HeaderLinks)/HeaderLinks/HeaderLink) &gt;0">
                                        <table cellpadding="0" cellspacing="0" border="0" class="tableMaster">
                                            <tr>
                                                <td style="text-align: center; vertical-align: middle;">
                                                    <xsl:for-each select="msxsl:node-set($HeaderLinks)/HeaderLinks/HeaderLink">
                                                        <xsl:if test="normalize-space(Type) = 'Anchor'">
                                                            <span style="margin-left: 10px; margin-right: 10px;">
                                                                <a href="{normalize-space(LinkUrl)}" class="link">
                                                                    <xsl:value-of select="DisplayText"></xsl:value-of>
                                                                </a>
                                                            </span>
                                                        </xsl:if>
                                                        <xsl:if test="normalize-space(Type) = 'AjaxCall'">
                                                            <span style="margin-left: 10px; margin-right: 10px;"
                                                                   onClick="{normalize-space(LinkUrl)}">
                                                                <a class="link">
                                                                    <xsl:value-of select="DisplayText"></xsl:value-of>
                                                                </a>
                                                            </span>
                                                        </xsl:if>
                                                    </xsl:for-each>
                                                </td>
                                            </tr>
                                        </table>
                                    </xsl:if>
                                </td>
                                <td align="right" valign="top" width="40px">
                                    <xsl:if test ="normalize-space($ShowCrossButton) = 'true'">
                                        <div onClick='{normalize-space($ShowCrossButtonFunction)}'
                                             style='text-align:right;margin:5px;'>
                                            <span class='link'>
                                                <xsl:text>[ X ]</xsl:text>
                                            </span>
                                        </div>
                                    </xsl:if>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div id="{normalize-space($IdPrefix)}_ContainerBox"
                             style="margin:{normalize-space($Content_LeftMargin)}px;">
                            <xsl:value-of select="normalize-space($Content)"
                                          disable-output-escaping="yes"></xsl:value-of>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>
</xsl:stylesheet>
