<?xml version="1.0" encoding="UTF-8"?>																							
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">

    <!--
    template    : .xsl
    context     : 
    description : transforms the given deck.xml into a virtual flascard set

    Author   Date      Version Work: Adding several new functions
    - - -    - - - - -   - -   - - - - - - - - - - - - - - - - - - - - - - - - - - 
    S.Yayla  2008.05.01    1   original
    S.Yayla  2008.05.02    2   added grp as param for later use in 5 step Leitner
    S.Yayla  2008.05.11    2   simplified the layout
    -->

    <!--  parameters that may be sent by calling party    -->
   	<xsl:param name="focus"     	/>
  	<xsl:param name="side"  	/>
  	<xsl:param name="grp"  	/>

    <xsl:output method="xml" indent="yes"/>

	<!-- - - - - - - - - - - - - - - - - - -

		  document
	- - - - - - - - - - - - - - - - - -  -->
    <xsl:template match="*|/">
        <xsl:apply-templates/>
    </xsl:template>

	<!-- - - - - - - - - - - - - - - - - - -
	-
	-	  deck 
	- - - - - - - - - - - - - - - - - -  -->
 	<xsl:template match="deck">
 	  <xsl:variable name="numberofcards" select="count(//card)"/>
	  <div><table width="500">
 	  <xsl:for-each select="card[position()=$focus]">
		<xsl:choose>
		    <xsl:when test="$side='front'">
			<tr height="300"><td class="front" colspan="2">
			 <span class="subject">(<xsl:value-of select="/deck/title"/>: 
			     card <xsl:value-of select="$focus"/> of <xsl:value-of select="$numberofcards"/>)</span>
                          <br/><br/>
			 <span class="front"><xsl:value-of select="front"/></span>
                          <br/><br/>
			 <span class="back"><br/><br/>&#160;</span>
                          <br/>
			</td></tr>
			<tr ><td> <span class="focus"> <a
                  ><xsl:attribute name="href">Javascript:{showCard('<xsl:value-of select="$focus"/>','back','0');}</xsl:attribute
                  ><xsl:attribute name="title">show the answer for this question, to see if it matches what I think it is.</xsl:attribute
                  >show the answer</a></span>
			</td><td>  <span class="defocus"> previous &#160; next   &#160;    
                  <input type="text" name="newfocus" id="newfocus" size="4">
                      <xsl:attribute name="value"><xsl:value-of select="$focus"/></xsl:attribute></input>
                  <xsl:text> </xsl:text>
                  Go 
			</span>
			</td></tr>
		    </xsl:when>
		    <xsl:otherwise>
			<tr height="300"><td class="back" colspan="2">
			 <span class="subject">(<xsl:value-of select="/deck/title"/>: 
			     card <xsl:value-of select="$focus"/> of <xsl:value-of select="$numberofcards"/>)</span>
                         <br/><br/>
			 <span class="front"><xsl:value-of select="front"/>&#160;</span>
                          <br/><br/>
			 <span class="back"><xsl:value-of select="back"/>&#160;</span>
                          <br/>
			</td></tr>
			<tr ><td> <span class="defocus"> show the answer </span>
			</td><td> <xsl:if test="$focus='1'"><span class="defocus">previous</span></xsl:if>
			      <xsl:if test="$focus!='1'"><span class="focus"> 
                  <a><xsl:attribute name="href">Javascript:{showCard('<xsl:value-of select="number($focus)-1"/>','front','<xsl:value-of select="$grp"/>');}</xsl:attribute
                  ><xsl:attribute name="title">move backward to the previous card</xsl:attribute
                  >previous</a>  
                  </span></xsl:if>
                  <xsl:if test="number($focus)=$numberofcards"><span class="defocus">next</span></xsl:if>
			      <xsl:if test="number($focus)!=$numberofcards"><span class="focus"> &#160; 
                  <a><xsl:attribute name="href">Javascript:{showCard('<xsl:value-of select="$focus+1"/>','front','<xsl:value-of select="$grp"/>');}</xsl:attribute
                  ><xsl:attribute name="title">move backward to the next card</xsl:attribute
                  >next</a> &#160;    
                  <input type="text" name="newfocus" id="newfocus" size="4">
                      <xsl:attribute name="value"><xsl:value-of select="$focus"/></xsl:attribute></input>
                  <xsl:text> </xsl:text>
                  <a type="button" name="go" id="go">
                      <xsl:attribute name="href">javascript:{showCard(document.forms[0].newfocus.value,'front','<xsl:value-of select="$grp"/>');}</xsl:attribute
                  >Go</a>  
                  </span></xsl:if>
			</td></tr>
		    </xsl:otherwise>
		</xsl:choose>
	</xsl:for-each>
	</table></div>
	</xsl:template>

</xsl:stylesheet>



