<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- localized strings -->
<xsl:variable name='ColumnHeader_Date'>Date/Time</xsl:variable>
<xsl:variable name='ColumnHeader_From'>From</xsl:variable>
<xsl:variable name='ColumnHeader_Message'>Message</xsl:variable>

<!-- variables -->
<xsl:variable name='Debug'>0</xsl:variable>

<xsl:variable name='TableStyle'>font-family:verdana; font-size:67%; text-align:left; vertical-align:top; table-layout:fixed</xsl:variable>
<xsl:variable name='GutterStyle'>width:2ex</xsl:variable>
<xsl:variable name='HeaderStyle'>border-bottom:1 solid black</xsl:variable>

<xsl:variable name='UseZebraStripe'>1</xsl:variable>
<xsl:variable name='ZebraStripeStyle'>background-color:#e0edff</xsl:variable>

<xsl:variable name='MostRecentSessionFirst'>0</xsl:variable>


<xsl:template match="Log">

    <html dir='ltr'>
    <head>
        <title>
            Message Log for <xsl:value-of select="@LogonName"/>
            <xsl:if test="$Debug = 1"> (Debug)</xsl:if>
        </title>

        <xsl:if test="$Debug = 1">
            <span style="font-family:trebuchet ms; font-size:120%">
                Debug Version
            </span>
            <hr/>
        </xsl:if>
    </head>

    <body style='margin:10' bgcolor='959595'><center>
        <table bgcolor='#CED6E0' id='BodyTable' style="font-family: Verdana, Arial; font-size:14px; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black;" width='75%' cellspacing='0'>

            <xsl:if test="$Debug = 1">
                <col style="vertical-align:top;"/>
               </xsl:if>

            <col />
                 <col />
                     <col />
                        <col />
                       <col />

            <thead>
                <tr>
                    <xsl:if test="$Debug = 1">
                        <th style="{$HeaderStyle}">SID</th>
                                            </xsl:if>
                    <th style="{$HeaderStyle}">
                        <xsl:value-of select="$ColumnHeader_Date"/>
                    </th>
                                                            <th style="{$HeaderStyle}">
                        <xsl:value-of select="$ColumnHeader_From"/>
                    </th>
                                        <th style="{$HeaderStyle}">
                        <xsl:value-of select="$ColumnHeader_Message"/>
</th>
                                    </tr>
            </thead>

            <tbody style='vertical-align:top'>
                       <xsl:apply-templates>
                            <xsl:sort select='@SessionID' order='ascending' data-type='number'/>
                            <xsl:sort select='@DateTime'  order='ascending'/>
                        </xsl:apply-templates>
                                </tbody>
        </table></center>
    </body>
    </html>

</xsl:template>


<xsl:template match="Message">
    <tr>
        <xsl:call-template name="CommonMessageProcessing" />

        <td bgcolor='#dddddd' style='border-bottom: 1px solid black; border-left: 1px solid black; border-collapse: collapse; padding: 5px;' valign='bottom'> <xsl:apply-templates select="From/User"/> says:<br /></td>
        <td style='border-bottom: 1px solid black; border-left: 1px solid black; border-collapse: collapse; padding: 5px;' valign='bottom'>
            <span>
                <xsl:attribute name="style">
                    <xsl:value-of select="Text/@Style"/>
                </xsl:attribute>
                <xsl:value-of select="Text"/>
            </span>
        </td>
    </tr>
</xsl:template>


<xsl:template match="Invitation|InvitationResponse|Join|Leave">
    <tr>
        <xsl:call-template name="CommonMessageProcessing" />

          <!-- From -->
          <!-- To -->
        <td style='border-bottom: 1px solid black; border-left: 1px solid black; border-collapse: collapse; padding: 5px;' valign='bottom'>
            .
        </td><td style='border-bottom: 1px solid black; border-left: 1px solid black; border-collapse: collapse; padding: 5px;' valign='bottom'><span>
                <xsl:attribute name="style">
                    <xsl:value-of select="Text/@Style"/>
                </xsl:attribute>
                <xsl:value-of select="Text"/>
            </span></td>
    </tr>
</xsl:template>


<xsl:template match="User">
    <!-- add a comma before all but the first user -->
    <xsl:if test="position() != 1">, </xsl:if>

    <xsl:value-of select="@FriendlyName"/>
</xsl:template>


<xsl:template name="CommonMessageProcessing">
    <!-- zebra-stripe the sessions -->
    <xsl:if test="$UseZebraStripe = 1">
        <xsl:if test="(@SessionID mod 2) = 1">
            <xsl:attribute name="style">
                <xsl:value-of select="$ZebraStripeStyle"/>
            </xsl:attribute>
        </xsl:if>
    </xsl:if>

    <xsl:if test="$Debug = 1">
        <td> <xsl:value-of select="@SessionID"/> </td>
        
    </xsl:if>

    <td style='border-bottom: 1px solid black; border-collapse: collapse; padding: 5px;' valign='bottom'> <b><xsl:value-of select="@Date"/></b> <br /><xsl:value-of select="@Time"/> </td>
    
</xsl:template>


</xsl:stylesheet>

