<?xml     version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:ccbnxml="http://xml.corporate-ir.net" exclude-result-prefixes="xsl xmlns ccbnxml">
    <!--'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    INCLUDES
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''-->
    <!--'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    OUTPUT MEHTOD
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''-->
    <xsl:output method="html" omit-xml-declaration="yes" indent="yes" standalone="no"/>
  
    <xsl:template match="/">
           <xsl:variable name="strLanguage" select="'FRC'" />
      <xsl:choose>
        <xsl:when test="$strLanguage = 'ENC'">
            <xsl:call-template name="EN"/>
        </xsl:when>  
        <xsl:otherwise>
            <xsl:call-template name="FR"/>
        </xsl:otherwise>
      </xsl:choose> 
    </xsl:template>
    
    <xsl:template name="FR">
        <div style="padding:0 10px 5px 10px;">
            <xsl:for-each select="//Events/Event[substring-after(EventTitle, 'R&#233;sultats') = '' and @EventStatus='0']">        
                <xsl:sort select="@EventStartDate" order="descending" />
                     <xsl:if test="position() = 1">

                         <!--display nicely formatted Start Date-->
                                <span style="font-weight : bold "><xsl:call-template name="DisplayDateFR">
                                      <xsl:with-param name="strDate" select="DisplayableDatesTimes/DisplayableDateTime/@EventStartDate"/>
                                </xsl:call-template></span>

                                <span style="font-weight : bold "><xsl:call-template name="DisplayTimeFR">
                                    <xsl:with-param name="strTime" select="DisplayableDatesTimes/DisplayableDateTime/@EventStartTime"/>
                                </xsl:call-template></span>
                            <br />
                            <xsl:value-of select="EventTitle"/>

                        <br /><br />

                        <a href="/fr/investisseurs/calendrier/4819.asp?EventId={@EventID}" target="_top">Encore Plus</a> | <a href="/fr/investisseurs/calendrier/4819.asp"  target="_top">Archives</a>

                        <br/>
                           
                    </xsl:if>                                                          
             </xsl:for-each>  
        </div>   
    </xsl:template>

    <xsl:template name="EN">
   
    
        <div style="padding:0 10px 5px 10px;">
            <xsl:for-each select="//Events/Event[substring-after(EventTitle, 'Earnings Relea') = '' and @EventStatus='0']">    
                <xsl:sort select="@EventStartDate" order="descending" />
                    <xsl:if test="position() = 1">

                            <!--display nicely formatted Start Date-->
                                <span style="font-weight : bold "><xsl:call-template name="DisplayDateEN">
                                    <xsl:with-param name="strDate" select="DisplayableDatesTimes/DisplayableDateTime/@EventStartDate"/>
                                </xsl:call-template></span>

                                <span style="font-weight : bold "><xsl:call-template name="DisplayTimeEN">
                                    <xsl:with-param name="strTime" select="DisplayableDatesTimes/DisplayableDateTime/@EventStartTime"/>
                                </xsl:call-template></span>       
                            <br />
                            <xsl:value-of select="EventTitle"/>

                        <br /><br />
                        
                        <a href="/fr/investisseurs/calendrier/4819.asp?EventId={@EventID}"  target="_top">See More</a> | <a href="/fr/investisseurs/calendrier/4819.asp"  target="_top">Archives</a>

                    </xsl:if>
            </xsl:for-each>  
        </div>   
    </xsl:template>
    
    <xsl:template name="DisplayDateEN">
        <xsl:param name="strDate"/>
        <!--strDate is assumed to be in yyyymmdd format-->
        <!--year parse-->
        <xsl:variable name="strYear" select="substring($strDate,1,4)"/>
        <!--month parse and string map-->
        <xsl:variable name="intMonth">
            <xsl:value-of select="substring($strDate,5,2)"/>
        </xsl:variable>
        <xsl:variable name="strMonth">
            <xsl:if test="$intMonth='01'">January</xsl:if>
            <xsl:if test="$intMonth='02'">February</xsl:if>
            <xsl:if test="$intMonth='03'">March</xsl:if>
            <xsl:if test="$intMonth='04'">April</xsl:if>
            <xsl:if test="$intMonth='05'">May</xsl:if>
            <xsl:if test="$intMonth='06'">June</xsl:if>
            <xsl:if test="$intMonth='07'">July</xsl:if>
            <xsl:if test="$intMonth='08'">August</xsl:if>
            <xsl:if test="$intMonth='09'">September</xsl:if>
            <xsl:if test="$intMonth='10'">October</xsl:if>
            <xsl:if test="$intMonth='11'">November</xsl:if>
            <xsl:if test="$intMonth='12'">December</xsl:if>
        </xsl:variable>
        <!--day parse and remove trailing 0 if applicable-->
        <xsl:variable name="strDay">
            <xsl:choose>
                <xsl:when test="substring($strDate,7,1) = '0'">
                    <xsl:value-of select="substring($strDate,8,1)"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="substring($strDate,7,2)"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!--display date as Dec. mm, YYYY-->
        <xsl:value-of select="concat($strMonth,' ',$strDay,', ',$strYear)"/>
    </xsl:template>

    <xsl:template name="DisplayDateFR">
        <xsl:param name="strDate"/>
        <!--strDate is assumed to be in yyyymmdd format-->
        <!--year parse-->
        <xsl:variable name="strYear" select="substring($strDate,1,4)"/>
        <!--month parse and string map-->
        <xsl:variable name="intMonth">
            <xsl:value-of select="substring($strDate,5,2)"/>
        </xsl:variable>
        <xsl:variable name="strMonth">
            <xsl:if test="$intMonth='01'">Janvier</xsl:if>
            <xsl:if test="$intMonth='02'">F&#233;vrier</xsl:if>
            <xsl:if test="$intMonth='03'">Mars</xsl:if>
            <xsl:if test="$intMonth='04'">Avril</xsl:if>
            <xsl:if test="$intMonth='05'">Mai</xsl:if>
            <xsl:if test="$intMonth='06'">Juin</xsl:if>
            <xsl:if test="$intMonth='07'">Juillet</xsl:if>
            <xsl:if test="$intMonth='08'">Ao&#251;t</xsl:if>
            <xsl:if test="$intMonth='09'">Septembre</xsl:if>
            <xsl:if test="$intMonth='10'">Octobre</xsl:if>
            <xsl:if test="$intMonth='11'">Novembre</xsl:if>
            <xsl:if test="$intMonth='12'">D&#233;cembre</xsl:if>
        </xsl:variable>
        <!--day parse and remove trailing 0 if applicable-->
        <xsl:variable name="strDay">
            <xsl:choose>
                <xsl:when test="substring($strDate,7,1) = '0'">
                    <xsl:value-of select="substring($strDate,8,1)"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="substring($strDate,7,2)"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!--display date as Dec. mm, YYYY-->
        <xsl:value-of select="concat('Le ',$strDay,' ',$strMonth,' ',$strYear)"/>
    </xsl:template>

    <xsl:template name="DisplayTimeEN">
        <xsl:param name="strTime"/>
        <!--strTime is assumed to be in 00:00:00 format-->
        <xsl:if test="string-length($strTime) &gt; 0">
            <!--hour parse-->
            <xsl:variable name="intHour" select="substring($strTime,1,2)"/>
            <!--minute parse-->
            <xsl:variable name="intMinute" select="substring($strTime, 4,2)"/>
            <!--display time-->
            <xsl:choose>
                <xsl:when test="number($intHour) &lt; 12">
                    <xsl:variable name="strHour">
                        <xsl:choose>
                            <xsl:when test="number($intHour) &lt; 10">
                                <xsl:value-of select="substring($intHour, 2, 1)"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$intHour"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:value-of select="concat(' at ', $strHour, ':', $intMinute, ' a.m ET')"/>
                </xsl:when>
                <xsl:when test="number($intHour) = 12">
                    <xsl:value-of select="concat(' at ', $intHour, ':', $intMinute, ' p.m ET')"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:variable name="intNonMilitaryHour" select="number($intHour) - 12"/>
                    <xsl:variable name="strHour">
                        <xsl:choose>
                            <xsl:when test="number($intNonMilitaryHour) &lt; 10">
                                <xsl:value-of select="substring(string($intNonMilitaryHour), 1, 1)"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$intNonMilitaryHour"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:value-of select="concat(' at ', $strHour, ':', $intMinute, ' p.m ET')"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:template>

    <xsl:template name="DisplayTimeFR">
        <xsl:param name="strTime"/>
        <!--strTime is assumed to be in 00:00:00 format-->
        <xsl:if test="string-length($strTime) &gt; 0">
            <!--hour parse-->
            <xsl:variable name="intHour" select="substring($strTime,1,2)"/>
            <!--minute parse-->
            <xsl:variable name="intMinute" select="substring($strTime, 4,2)"/>
            <!--display time-->
        <xsl:value-of select="concat(' &#224; ', $intHour, 'h', $intMinute)"/>
        </xsl:if>
    </xsl:template>

</xsl:stylesheet>
