<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
   
   <xsl:output method="html"/>
   
   <xsl:template match="/">
   <html>
   <head>
      <title><xsl:value-of select="/rss/channel/title"/></title>
      <link rel="stylesheet" type="text/css" href="./style/styles.css" />
      <link rel="alternate" type="application/rss+xml" title="{/rss/channel/title}" href="{/rss/channel/link}"/>
   </head>
   <body>
   
      <div id="logobar">
         <div id="banner">
            <img src="http://video.hbs.edu/videotools/hbs/images/videotools.gif"
              border="0"/>
         </div>
         <div id="subbanner"><xsl:value-of select="/rss/channel/title"/></div>
         <div id="shield"><img 
               src="http://video.hbs.edu/videotools/hbs/images/shield.gif" 
               alt="HBS" border="0"/></div>
      </div>

      <div id="content">
      
         <b>About this content feed</b>
         
         <p>
            This RSS feed provides direct links to streamed content from the
            HBS Videotools library. Note that access to some of the content may
            require you to login to the HBS intranet.
         </p>
   
   
         <b>How do I subscribe to this feed?</b>
         
         <p>
            If your browser is displaying the "Live Bookmarks" icon
         </p>
         
         <p style="padding-left:40px;"><img src="./style/livebookmarksicon.png"/></p>
         
         <p>
            either in the location bar or in the lower right-hand corner,
            you can add this feed directly to your bookmarks by clicking the icon.
         </p>
         
         <p>
            Or copy the URL in the box below into your preferred RSS reader. 
            You will automatically receive this podcast each time it's published.
         </p>
      
         <input type="text" size="84" id="podurl" 
            value="{/rss/channel/link}" onclick="this.select();" />


         <p><hr size="1"/></p>
         
         <xsl:apply-templates select="rss/channel"/>


      </div>

   </body>
   </html>
   </xsl:template>
   
   <xsl:template match="channel">
      <h3><xsl:value-of select="./title"/></h3>
      <xsl:for-each select="item">
      <p>
         <b><xsl:value-of select="./title"/></b><br/>
         <xsl:value-of select="./description"/>
      </p>
      </xsl:for-each>
   </xsl:template>
   
   <xsl:template name="replace">
      <xsl:param name="stringIn"/>
      <xsl:param name="charsOut"/>
      <xsl:param name="charsIn"/>
      <xsl:choose>
         <xsl:when test="contains($stringIn, $charsOut)">
            <xsl:value-of select="concat(substring-before($stringIn, $charsOut), $charsIn)"/>
            <xsl:call-template name="replace">
               <xsl:with-param name="stringIn" select="substring-after($stringIn, $charsOut)"/>
               <xsl:with-param name="charsOut" select="$charsOut"/>
               <xsl:with-param name="charsIn" select="$charsIn"/>
            </xsl:call-template>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$stringIn"/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>
   
</xsl:stylesheet>