<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="html"/>

	<xsl:template match="/">
		<div id="FormCalendar">
			<xsl:apply-templates select="@name" />
			<xsl:apply-templates select="//calendar" />
		</div>
	</xsl:template>

	<xsl:template match="calendar">
		<table class="nav">
			<tr>
				<td onclick="_FormCalendar.backOneMonth();"><a href="javascript:void(0);">&lt;</a></td>
				<td><h4><xsl:value-of select="@name" /></h4></td>
				<td onclick="_FormCalendar.forwardOneMonth();"><a href="javascript:void(0);">&gt;</a></td>
			</tr>
		</table>
		<table class="cal">
			<xsl:apply-templates select="//weekdays" />
			<xsl:apply-templates select="week" />
		</table>
		<a id="FormCalendar_thisdate" href="javascript:_FormCalendar.toTodaysDate();">return to today</a>
	</xsl:template>

	<xsl:template match="week">
		<tr>
		<xsl:apply-templates select="date" />
		</tr>
	</xsl:template>

	<xsl:template match="date">
		<td onmouseover="if (this.className!='outOfMonth') this.className='on';">
			<xsl:attribute name="onmouseout">
				if (this.className=='on') this.className='<xsl:value-of select="@type" />';
			</xsl:attribute>
			<xsl:if test="not(@type='outOfMonth')">
				<xsl:attribute name="onclick">
					alert("The date selected is: "+(_FormCalendar.date.getMonth()+1)+"/"+this.innerHTML+"/"+_FormCalendar.date.getFullYear()+"\nThere could be some javascript here that copies the result to a text field. \n(That's next week's post, actually, where a generic date formatter will be useful.)");
				</xsl:attribute>
			</xsl:if>
			<xsl:attribute name="class"><xsl:value-of select="@type" /></xsl:attribute>
			<xsl:if test="not(string(@day))">&#160;</xsl:if>
			<xsl:value-of select="@day" disable-output-escaping="yes" />
		</td>
	</xsl:template>

	<xsl:template match="weekdays">
		<thead>
			<xsl:apply-templates select="day" />
		</thead>
	</xsl:template>

	<xsl:template match="day">
		<td>
			<xsl:if test="not(string(@abbr))">&#160;</xsl:if>
			<xsl:value-of select="@abbr" disable-output-escaping="yes" />
		</td>
	</xsl:template>

</xsl:stylesheet>
