<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" indent="yes" /> 

	<!-- This template will output the reminder icon and link -->
	<xsl:template match="reminderlink">
		<img src="Images/spacer.gif" width="20" height="1" /> <!-- horizontal spacer image -->
		<a>
			<xsl:attribute name="href"><xsl:apply-templates select="." mode="href"/></xsl:attribute>
			<img align="top" src="Questions/images/remind.gif" width="16" height="15" border="0" />
		</a>
		<img src="Images/spacer.gif" width="5" height="1" /> <!-- horizontal spacer image -->
		<a>
			<xsl:attribute name="href"><xsl:apply-templates select="." mode="href"/></xsl:attribute>Remind me later
		</a>
	</xsl:template>

	<!-- This template will output the javascript command -->
<xsl:template match="reminderlink" mode="href"><xsl:variable name="profile" select="alertprofile"/>javascript:CreateNewAlert('<xsl:call-template name="escape-apos"><xsl:with-param name="string" select="alertname"/></xsl:call-template>', '<xsl:call-template name="escape-apos"><xsl:with-param name="string" select="alerttext"/></xsl:call-template>', '<xsl:call-template name="escape-apos"><xsl:with-param name="string" select="../command"/></xsl:call-template>', '<xsl:call-template name="escape-apos"><xsl:with-param name="string" select="alertprofile"/></xsl:call-template>', '<xsl:value-of select="daysuntildue"/>',  '<xsl:value-of select="daysbefore"/>', '<xsl:value-of select="daysafter"/>')</xsl:template>

<xsl:template name="escape-apos">
   <xsl:param name="string" />

   <!-- create an $apos variable to make it easier to refer to -->
   <xsl:variable name="apos" select='"&apos;"'/>

   <xsl:choose>
      <!-- if the string contains an apostrophe... -->
      <xsl:when test="contains($string, $apos)">
         <!-- ... give the value before the apostrophe... -->
         <xsl:value-of select="substring-before($string, $apos)" />
         <!-- ... the escaped apostrophe ... -->
         <xsl:text>\'</xsl:text>
         <!-- ... and the result of applying the template to the
                  string after the apostrophe -->
         <xsl:call-template name="escape-apos">
            <xsl:with-param name="string" select="substring-after($string, $apos)" />
         </xsl:call-template>
      </xsl:when>
      <!-- otherwise... -->
      <xsl:otherwise>
         <!-- ... just give the value of the string -->
         <xsl:value-of select="$string" />
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>

</xsl:stylesheet>
