<?xml version = "1.0"?>
<!DOCTYPE xsl:stylesheet SYSTEM "file:///C:/PROGRAM FILES/EXTENSIBILITY/XI11/intrinsics/xslt.dtd">
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" xmlns:x = "http://www.mozquito.org/xhtml-fml">        
	<xsl:output method = "xml" indent = "yes" doctype-system = "http://www.mozquito.org/dtd/xhtml-fml1.dtd" doctype-public = "-//OVERFLOW//DTD XHTML-FML 1.0//EN"/>
	<xsl:template match = "*|/">
		<xsl:apply-templates select = "node()"/>
	</xsl:template>
	<xsl:template match = "text()|@*">
		<xsl:value-of select = "." disable-output-escaping = "no"/>
	</xsl:template>
	<xsl:template match = "TimeSheetDoc">
		<html xmlns = "http://www.w3.org/1999/xhtml" xmlns:x = "http://www.mozquito.org/xhtml-fml">
			<head>
				<title>WebTCAS xsl xhtml Mozquito Prototype</title>        
			</head>
			<body>
				<h3>WebTCAS xsl xhtml Mozquito Prototype</h3>
				<hr/>
				<x:form id = "TAForm" action = "http://www.mozquito.org/servlets/Echo" method = "post">
					<x:button id = "tgTimeSheet" value = "Time Sheet" onclick = "toggle:parts,TimeSheet"/>
					<x:button id = "tgLeaveBalance" value = "Leave Balances" onclick = "toggle:parts,LeaveBalance"/>
					<x:button id = "tgNote" value = "Note" onclick = "toggle:parts,Note"/>
					<x:button id = "submit" value = "Submit" onclick = "submit:TAForm"/>
					<br/>
					<br/>
					<x:toggle id = "parts">
						<xsl:apply-templates select = "//TimeSheet"/>
						<xsl:apply-templates select = "//Employee" mode = "balances"/>
						<xsl:apply-templates select = "//*/Note"/>
					</x:toggle>
				</x:form>
			</body>
		</html>
	</xsl:template>
	<xsl:template match = "Employee" mode = "balances">
		<x:tg id = "LeaveBalance">
			<xsl:call-template name = "HeadingA">
				<xsl:with-param name = "cell2" select = "'Current Leave Balances'"/>
			</xsl:call-template>
			<table border = "1" frame = "box" rules = "all" width = "100%">
				<tbody>
					<tr>
						<td align = "left" width = "20%">Leave Type</td>
						<td align = "center" width = "15%">Brought Forward</td>
						<td align = "center" width = "10%">PTCO</td>
						<td align = "center" width = "10%">Accured</td>
						<td align = "center" width = "10%">Used</td>
						<td align = "center" width = "15%">New Balance</td>
						<td align = "center" width = "10%">PTCO</td>
						<td align = "center" width = "10%">Ceiling</td>
					</tr>
					<xsl:apply-templates select = "//LeaveBalanceSet/Code[@CodeClass='CoreLeave']/.." mode = "full"/>
				</tbody>
			</table>
			<table border = "1" frame = "box" rules = "all" width = "100%" cellpadding = "50">
				<tbody>
					<tr>
						<td align = "center" valign = "middle" width = "50%">
							<table border = "1" frame = "box" rules = "all" width = "100%">
								<tbody>
									<tr>
										<td align = "center" colspan = "2">Other Leave Balances (Brought Forward)</td>
									</tr>
									<xsl:apply-templates select = "//LeaveBalanceSet/Code[@CodeClass='OtherLeave']/.." mode = "balanceonly"/>
								</tbody>
							</table>
						</td>
						<td align = "center" valign = "middle" width = "50%">
							<table border = "1" frame = "box" rules = "all" width = "100%">
								<tbody>
									<tr>
										<td align = "center" colspan = "2">Recorded To Date (Brought Forward)</td>
									</tr>
									<xsl:apply-templates select = "//LeaveBalanceSet/Code[@CodeClass='ToDate']/.." mode = "balanceonly"/>
								</tbody>
							</table>
						</td>
					</tr>
				</tbody>
			</table>
		</x:tg>
	</xsl:template>
	<xsl:template match = "LeaveBalanceSet" mode = "balanceonly">
		<xsl:if test = "not(document('rules.xml')//SumRule[@Type='Sum' and @ItemCode=current()/Code/@Code])">
			<tr>
				<td>
					<xsl:value-of select = "Code/@Name" disable-output-escaping = "no"/>
				</td>
				<xsl:variable name = "type">
					<xsl:choose>
						<xsl:when test = "Code/@CodeClass = 'OtherLeave'">
							<xsl:value-of select = "'Current'" disable-output-escaping = "no"/>
						</xsl:when>
						<xsl:when test = "Code/@CodeClass = 'ToDate'">
							<xsl:value-of select = "'YTD'" disable-output-escaping = "no"/>
						</xsl:when>
					</xsl:choose>
				</xsl:variable>
				<xsl:variable name = "theBalanceID" select = "concat('balance-',Code/@CodeClass,Code/@Code,'-',$type)"/>
				<xsl:variable name = "theTerm">
					<xsl:choose>
						<xsl:when test = "document('rules.xml')//SumRule[@Type='Sum' and @SumCode=current()/Code/@Code]">
							<xsl:call-template name = "itemSum">
								<xsl:with-param name = "theList" select = "document('rules.xml')//SumRule[@Type='Sum' and @SumCode=current()/Code/@Code]"/>
							</xsl:call-template>
						</xsl:when>
						<xsl:when test = "Balance[@Type=$type]/@Amount">
							<xsl:value-of select = "Balance[@Type=$type]/@Amount" disable-output-escaping = "no"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select = "'----'" disable-output-escaping = "no"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<td align = "right">
					<x:calc id = "{$theBalanceID}-Calc" digits = "2" term = "{$theTerm}">
						<x:textoutput id = "{$theBalanceID}" send = "false"/>
					</x:calc>
				</td>
			</tr>
		</xsl:if>
	</xsl:template>
	<xsl:template name = "itemSum">
		<xsl:param name = "theList"/>
		<xsl:value-of select = "sum(//LeaveBalanceSet/Code[@Code = $theList/@ItemCode]/../Balance[@Type='YTD']/@Amount)" disable-output-escaping = "no"/>
	</xsl:template>
	<xsl:template match = "LeaveBalanceSet" mode = "full">
		<tr>
			<td>
				<xsl:value-of select = "Code/@Name" disable-output-escaping = "no"/>
			</td>
			<xsl:variable name = "type" select = "'Current'"/>
			<xsl:variable name = "theCurrentID" select = "concat('balance-',Code/@CodeClass,Code/@Code,'-',$type)"/>
			<xsl:variable name = "theValue">
				<xsl:choose>
					<xsl:when test = "Balance[@Type=$type]/@Amount">
						<xsl:value-of select = "Balance[@Type=$type]/@Amount" disable-output-escaping = "no"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select = "'0.00'" disable-output-escaping = "no"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<td align = "right">
				<x:textoutput id = "{$theCurrentID}" send = "false" value = "{$theValue}"/>
			</td>
			<xsl:variable name = "type" select = "'PTCO-BF'"/>
			<xsl:variable name = "thePTCO-BFID" select = "concat('balance-',Code/@CodeClass,Code/@Code,'-',$type)"/>
			<xsl:variable name = "theValue">
				<xsl:choose>
					<xsl:when test = "Balance[@Type=$type]/@Amount">
						<xsl:value-of select = "Balance[@Type=$type]/@Amount" disable-output-escaping = "no"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select = "'----'" disable-output-escaping = "no"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<td align = "right">
				<x:textoutput id = "{$thePTCO-BFID}" send = "false" value = "{$theValue}"/>
			</td>
			<xsl:variable name = "type" select = "'Accrual'"/>
			<xsl:variable name = "theAccrualID" select = "concat('balance-',Code/@CodeClass,Code/@Code,'-',$type)"/>
			<xsl:variable name = "theTerm">
				<xsl:choose>
					<xsl:when test = "Balance[@Type=$type]/@Amount">
						<xsl:value-of select = "Balance[@Type=$type]/@Amount" disable-output-escaping = "no"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:variable name = "sumList">
							<xsl:call-template name = "makeLeaveRuleList">
								<xsl:with-param name = "theList" select = "document('rules.xml')//LeaveRule[@Type=$type and @BalanceCode=current()/Code/@Code]"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:value-of select = "normalize-space(substring-after(concat('+ 0.00 ',$sumList),'+'))" disable-output-escaping = "no"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<td align = "right">
				<x:calc id = "{$theAccrualID}-Calc" digits = "2" term = "{$theTerm}">
					<x:textoutput id = "{$theAccrualID}" send = "false"/>
				</x:calc>
			</td>
			<xsl:variable name = "type" select = "'Used'"/>
			<xsl:variable name = "theUsedID" select = "concat('balance-',Code/@CodeClass,Code/@Code,'-',$type)"/>
			<xsl:variable name = "sumList">
				<xsl:call-template name = "makeLeaveRuleList">
					<xsl:with-param name = "theList" select = "document('rules.xml')//LeaveRule[@Type=$type and @BalanceCode=current()/Code/@Code]"/>
				</xsl:call-template>
			</xsl:variable>
			<td align = "right">
				<x:calc id = "{$theUsedID}-Calc" digits = "2" term = "{normalize-space(substring-after(concat('+ 0.00 ',$sumList),'+'))}">
					<x:textoutput id = "{$theUsedID}" send = "false"/>
				</x:calc>
			</td>
			<xsl:variable name = "type" select = "'New'"/>
			<xsl:variable name = "theNewID" select = "concat('balance-',Code/@CodeClass,Code/@Code,'-',$type)"/>
			<td align = "right">
				<x:calc id = "{$theNewID}-Calc" digits = "2" term = "{normalize-space(concat($theCurrentID,' + ',$theAccrualID,' - ',$theUsedID))}">
					<x:textoutput id = "{$theNewID}" send = "false"/>
				</x:calc>
			</td>
			<xsl:variable name = "type" select = "'PTCO-New'"/>
			<xsl:variable name = "thePTCO-NewID" select = "concat('balance-',Code/@CodeClass,Code/@Code,'-',$type)"/>
			<xsl:variable name = "theValue">
				<xsl:choose>
					<xsl:when test = "Balance[@Type=$type]/@Amount">
						<xsl:value-of select = "Balance[@Type=$type]/@Amount" disable-output-escaping = "no"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select = "'----'" disable-output-escaping = "no"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<td align = "right">
				<x:textoutput id = "{$thePTCO-NewID}" send = "false" value = "{$theValue}"/>
			</td>
			<xsl:variable name = "type" select = "'Ceiling'"/>
			<xsl:variable name = "theValue">
				<xsl:choose>
					<xsl:when test = "Balance[@Type=$type]/@Amount">
						<xsl:value-of select = "Balance[@Type=$type]/@Amount" disable-output-escaping = "no"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select = "'----'" disable-output-escaping = "no"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<xsl:variable name = "theID" select = "concat('balance-',Code/@CodeClass,Code/@Code,'-',$type)"/>
			<td align = "right">
				<x:textoutput id = "{$theID}" send = "false" value = "{$theValue}"/>
			</td>
		</tr>
	</xsl:template>
	<xsl:template name = "makeLeaveRuleList">
		<xsl:param name = "theList"/>
		<xsl:if test = "$theList">
			<xsl:if test = "//CodeSet/Code[@Code = $theList[1]/@EntryCode] ">
				<xsl:value-of select = "concat(' + hoursEntry-',$theList[1]/@EntryClass,$theList[1]/@EntryCode,'-PP')" disable-output-escaping = "no"/>
			</xsl:if>
			<xsl:call-template name = "makeLeaveRuleList">
				<xsl:with-param name = "theList" select = "$theList[position() != 1]"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	<xsl:template match = "TimeSheet">
		<x:tg id = "TimeSheet">
			<xsl:call-template name = "HeadingA">
				<xsl:with-param name = "cell2" select = "//*/WorkSchedule/@Name"/>
				<xsl:with-param name = "cell3" select = "'NRCS Fund ???????'"/>
			</xsl:call-template>
			<table border = "1" frame = "box" rules = "all" width = "100%">
				<tbody>
					<tr>
						<td colspan = "3"/>
						<xsl:call-template name = "dayHeading">
							<xsl:with-param name = "beginDay" select = "'1'"/>
							<xsl:with-param name = "endDay" select = "'7'"/>
						</xsl:call-template>
						<td width = "3"/>
						<xsl:call-template name = "dayHeading">
							<xsl:with-param name = "beginDay" select = "'8'"/>
							<xsl:with-param name = "endDay" select = "'14'"/>
						</xsl:call-template>
						<td width = "3"/>
						<td>PP</td>
					</tr>
					<xsl:call-template name = "TimeEntry"/>
				</tbody>
			</table>
			<br/>
			<br/>
			<br/>
			<xsl:call-template name = "HeadingA">
				<xsl:with-param name = "cell2" select = "'Clock Hours'"/>
			</xsl:call-template>
			<table border = "1" frame = "box" rules = "all" width = "100%">
				<tbody>
					<tr>
						<td colspan = "3"/>
						<xsl:call-template name = "dayHeading">
							<xsl:with-param name = "beginDay" select = "'1'"/>
							<xsl:with-param name = "endDay" select = "'7'"/>
						</xsl:call-template>
						<td width = "3"/>
						<xsl:call-template name = "dayHeading">
							<xsl:with-param name = "beginDay" select = "'8'"/>
							<xsl:with-param name = "endDay" select = "'14'"/>
						</xsl:call-template>
					</tr>
					<xsl:call-template name = "ClockHours"/>
				</tbody>
			</table>
		</x:tg>
	</xsl:template>
	<xsl:template name = "ClockHours">
		<xsl:call-template name = "catHeading">
			<xsl:with-param name = "title" select = "'Leave'"/>
			<xsl:with-param name = "listName" select = "'Leave Entry'"/>
		</xsl:call-template>
		<xsl:apply-templates select = "//TimeSheet/StartStopSet[@Name='Leave']" mode = "doSet"/>
		<tr>
			<td colspan = "20"/>
		</tr>
		<xsl:call-template name = "catHeading">
			<xsl:with-param name = "title" select = "'Actual Tour'"/>
			<xsl:with-param name = "listName" select = "'Actual Tour Entry'"/>
		</xsl:call-template>
		<xsl:apply-templates select = "//TimeSheet/StartStopSet[@Name='ActualTour']" mode = "doSet"/>
		<xsl:apply-templates mode = "doTime" select = "//TimeSheet/StartStopSet[@Name='ActualTour'][1]">
			<xsl:with-param name = "rowLabel" select = "'Lunch'"/>
			<xsl:with-param name = "clockAttr" select = "'Lunch'"/>
			<xsl:with-param name = "thePos" select = "'A1'"/>
		</xsl:apply-templates>
		<tr>
			<td colspan = "20"/>
		</tr>
		<xsl:call-template name = "catHeading">
			<xsl:with-param name = "title" select = "'Scheduled Tour'"/>
		</xsl:call-template>
		<xsl:apply-templates mode = "doTime" select = "//WorkSchedule">
			<xsl:with-param name = "rowLabel" select = "'From'"/>
			<xsl:with-param name = "clockAttr" select = "'Start'"/>
			<xsl:with-param name = "thePos" select = "'S1'"/>
		</xsl:apply-templates>
		<xsl:apply-templates mode = "doTime" select = "//WorkSchedule">
			<xsl:with-param name = "rowLabel" select = "'To'"/>
			<xsl:with-param name = "clockAttr" select = "'Stop'"/>
			<xsl:with-param name = "thePos" select = "'S1'"/>
		</xsl:apply-templates>
		<xsl:apply-templates mode = "doTime" select = "//WorkSchedule">
			<xsl:with-param name = "rowLabel" select = "'Lunch'"/>
			<xsl:with-param name = "clockAttr" select = "'Lunch'"/>
			<xsl:with-param name = "thePos" select = "'S1'"/>
		</xsl:apply-templates>
		<tr>
			<td colspan = "20"/>
		</tr>
	</xsl:template>
	<xsl:template name = "TimeEntry">
		<xsl:call-template name = "catHeading">
			<xsl:with-param name = "title" select = "'Projects: Prog/Activity'"/>
			<xsl:with-param name = "listName" select = "'Project'"/>
		</xsl:call-template>
		<xsl:apply-templates mode = "doRows" select = "//*[@CodeClass = 'Program']/.."/>
		<tr>
			<td colspan = "20"/>
		</tr>
		<xsl:call-template name = "catHeading">
			<xsl:with-param name = "title" select = "'Leave Used (Balance)'"/>
			<xsl:with-param name = "listName" select = "'Leave Type'"/>
		</xsl:call-template>
		<xsl:apply-templates mode = "doRows" select = "//*[@CodeClass = 'LeaveUsed']/.."/>
		<tr>
			<td colspan = "20"/>
		</tr>
		<xsl:call-template name = "weekTotals"/>
		<xsl:call-template name = "dayTotals"/>
		<xsl:apply-templates mode = "doHours" select = "//WorkSchedule"/>
		<tr>
			<td colspan = "20"/>
		</tr>
		<xsl:call-template name = "catHeading">
			<xsl:with-param name = "title" select = "'Above Tour'"/>
			<xsl:with-param name = "listName" select = "'Above Tour Category'"/>
		</xsl:call-template>
		<xsl:apply-templates mode = "doRows" select = "//*[@CodeClass = 'AboveTour']/.."/>
		<tr>
			<td colspan = "20"/>
		</tr>
	</xsl:template>
	<xsl:template name = "dayTotal">
		<xsl:param name = "cellPrefix"/>
		<xsl:param name = "firstDay"/>
		<xsl:param name = "lastDay"/>
		<xsl:if test = "$firstDay &lt;= $lastDay">
			<xsl:variable name = "sumList">
				<xsl:for-each select = "//*[@CodeClass = 'Program']/..">
					<xsl:variable name = "rowID">
						<xsl:apply-templates mode = "code" select = "Code"/>
					</xsl:variable>
					<xsl:value-of select = "concat(' + hoursEntry-',$rowID,'-',$firstDay)" disable-output-escaping = "no"/>
				</xsl:for-each>
				<xsl:for-each select = "//*[@CodeClass = 'LeaveUsed']/..">
					<xsl:variable name = "rowID">
						<xsl:apply-templates mode = "code" select = "Code"/>
					</xsl:variable>
					<xsl:value-of select = "concat(' + hoursEntry-',$rowID,'-',$firstDay)" disable-output-escaping = "no"/>
				</xsl:for-each>
			</xsl:variable>
			<td align = "right">
				<x:calc id = "{$cellPrefix}{$firstDay}-Calc" digits = "2" term = "{normalize-space(substring-after($sumList,'+'))}">
					<x:textoutput id = "{$cellPrefix}{$firstDay}" send = "false"/>
				</x:calc>
			</td>
			<xsl:call-template name = "dayTotal">
				<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
				<xsl:with-param name = "firstDay" select = "$firstDay + 1"/>
				<xsl:with-param name = "lastDay" select = "$lastDay"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	<xsl:template name = "dayTotals">
		<xsl:variable name = "cellPrefix" select = "'dayTotal-'"/>
		<tr>  
			<td colspan = "3" align = "center">Day Totals</td>
			<xsl:call-template name = "dayTotal">
				<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
				<xsl:with-param name = "firstDay" select = "'1'"/>
				<xsl:with-param name = "lastDay" select = "'7'"/>
			</xsl:call-template>
			<td width = "3"/>
			<xsl:call-template name = "dayTotal">
				<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
				<xsl:with-param name = "firstDay" select = "'8'"/>
				<xsl:with-param name = "lastDay" select = "'14'"/>
			</xsl:call-template>
			<td width = "3"/>
			<xsl:variable name = "sumList">
				<xsl:call-template name = "makeSumList">
					<xsl:with-param name = "cellNameTemplate" select = "concat($cellPrefix,'%-Calc')"/>
					<xsl:with-param name = "firstItem" select = "'1'"/>
					<xsl:with-param name = "lastItem" select = "'14'"/>
				</xsl:call-template>
			</xsl:variable>
			<td align = "right">
				<x:calc id = "{$cellPrefix}PP-Calc" digits = "2" term = "{normalize-space(substring-after($sumList,'+'))}">
					<x:textoutput id = "{$cellPrefix}PP" send = "false"/>
				</x:calc>
			</td>
		</tr>        
	</xsl:template>
	<xsl:template name = "weekTotals">
		<xsl:variable name = "cellPrefix" select = "'weekTotal-'"/>
		<tr>  
			<td colspan = "3" align = "center">Week Totals</td>
			<xsl:variable name = "sumList">
				<xsl:call-template name = "makeSumList">
					<xsl:with-param name = "cellNameTemplate" select = "'dayTotal-%-Calc'"/>
					<xsl:with-param name = "firstItem" select = "'1'"/>
					<xsl:with-param name = "lastItem" select = "'7'"/>
				</xsl:call-template>
			</xsl:variable>
			<td align = "center" colspan = "7">
				<x:calc id = "{$cellPrefix}W1-Calc" digits = "2" term = "{normalize-space(substring-after($sumList,'+'))}">
					<x:textoutput id = "{$cellPrefix}W1" send = "false"/>
				</x:calc>
			</td>
			<td width = "3"/>
			<xsl:variable name = "sumList">
				<xsl:call-template name = "makeSumList">
					<xsl:with-param name = "cellNameTemplate" select = "'dayTotal-%-Calc'"/>
					<xsl:with-param name = "firstItem" select = "'8'"/>
					<xsl:with-param name = "lastItem" select = "'14'"/>
				</xsl:call-template>
			</xsl:variable>
			<td align = "center" colspan = "7">
				<x:calc id = "{$cellPrefix}W2-Calc" digits = "2" term = "{normalize-space(substring-after($sumList,'+'))}">
					<x:textoutput id = "{$cellPrefix}W2" send = "false"/>
				</x:calc>
			</td>
			<td width = "3"/>
			<xsl:variable name = "sumList">
				<xsl:call-template name = "makeSumList">
					<xsl:with-param name = "cellNameTemplate" select = "'weekTotal-W%-Calc'"/>
					<xsl:with-param name = "firstItem" select = "'1'"/>
					<xsl:with-param name = "lastItem" select = "'2'"/>
				</xsl:call-template>
			</xsl:variable>
			<td align = "right">
				<x:calc id = "{$cellPrefix}PP-Calc" digits = "2" term = "{normalize-space(substring-after($sumList,'+'))}">
					<x:textoutput id = "{$cellPrefix}PP" send = "false"/>
				</x:calc>
			</td>
		</tr>        
	</xsl:template>
	<xsl:template match = "WorkSchedule" mode = "doHours">
		<tr>  
			<td align = "center" colspan = "3">Scheduled Hours</td>
			<xsl:variable name = "cellPrefix" select = "'scheduledHours-'"/>
			<xsl:call-template name = "makeDayCell">
				<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
				<xsl:with-param name = "cellType" select = "'scheduledHours'"/>
				<xsl:with-param name = "thisDay" select = "'1'"/>
				<xsl:with-param name = "lastDay" select = "'7'"/>
				<xsl:with-param name = "theList" select = "StartStop[@DayIndex &lt; 8]"/>
				<xsl:with-param name = "rowSpan" select = "'1'"/>
			</xsl:call-template>
			<td width = "3"/>
			<xsl:call-template name = "makeDayCell">
				<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
				<xsl:with-param name = "cellType" select = "'scheduledHours'"/>
				<xsl:with-param name = "thisDay" select = "'8'"/>
				<xsl:with-param name = "lastDay" select = "'14'"/>
				<xsl:with-param name = "theList" select = "StartStop[@DayIndex > 7]"/>
				<xsl:with-param name = "rowSpan" select = "'1'"/>
			</xsl:call-template>
			<td width = "3"/>
			<xsl:variable name = "sumList">
				<xsl:call-template name = "makeSumList">
					<xsl:with-param name = "cellNameTemplate" select = "concat($cellPrefix,'%')"/>
					<xsl:with-param name = "firstItem" select = "'1'"/>
					<xsl:with-param name = "lastItem" select = "'14'"/>
				</xsl:call-template>
			</xsl:variable>
			<td align = "right">
				<x:calc id = "{$cellPrefix}PP-Calc" digits = "2" term = "{normalize-space(substring-after($sumList,'+'))}">
					<x:textoutput id = "{$cellPrefix}PP" send = "false"/>
				</x:calc>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match = "StartStopSet" mode = "doSet">
		<xsl:apply-templates mode = "doTime" select = ".">
			<xsl:with-param name = "rowLabel" select = "'From'"/>
			<xsl:with-param name = "clockAttr" select = "'Start'"/>
			<xsl:with-param name = "thePos" select = "concat(substring(@Name,1,1),position())"/>
		</xsl:apply-templates>
		<xsl:apply-templates mode = "doTime" select = ".">
			<xsl:with-param name = "rowLabel" select = "'To'"/>
			<xsl:with-param name = "clockAttr" select = "'Stop'"/>
			<xsl:with-param name = "thePos" select = "concat(substring(@Name,1,1),position())"/>
		</xsl:apply-templates>
	</xsl:template>
	<xsl:template match = "WorkSchedule|StartStopSet" mode = "doTime">
		<xsl:param name = "rowLabel"/>
		<xsl:param name = "clockAttr"/>
		<xsl:param name = "thePos" select = "'1'"/>
		<tr>  
			<td align = "left" colspan = "3">
				<xsl:value-of select = "concat($rowLabel,':')" disable-output-escaping = "no"/>
			</td>
			<xsl:variable name = "cellPrefix" select = "concat($clockAttr,'-',$thePos,'-')"/>
			<xsl:call-template name = "makeDayCell">
				<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
				<xsl:with-param name = "cellType" select = "concat(substring($thePos,1,1),$clockAttr)"/>
				<xsl:with-param name = "thisDay" select = "'1'"/>
				<xsl:with-param name = "lastDay" select = "'7'"/>
				<xsl:with-param name = "theList" select = "StartStop[@DayIndex &lt; 8]"/>
				<xsl:with-param name = "rowSpan" select = "'1'"/>
			</xsl:call-template>
			<td width = "3"/>
			<xsl:call-template name = "makeDayCell">
				<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
				<xsl:with-param name = "cellType" select = "concat(substring($thePos,1,1),$clockAttr)"/>
				<xsl:with-param name = "thisDay" select = "'8'"/>
				<xsl:with-param name = "lastDay" select = "'14'"/>
				<xsl:with-param name = "theList" select = "StartStop[@DayIndex > 7]"/>
				<xsl:with-param name = "rowSpan" select = "'1'"/>
			</xsl:call-template>
			<td width = "3"/>
		</tr>
	</xsl:template>
	<xsl:template match = "CodeSet" mode = "doRows">
		<tr>  
			<td align = "left" colspan = "3">
				<xsl:apply-templates mode = "label" select = "Code[@CodeClass='Program' or @CodeClass='LeaveUsed' or @CodeClass='AboveTour']"/>
			</td>
			<xsl:variable name = "rowID">
				<xsl:apply-templates mode = "code" select = "Code"/>
			</xsl:variable>
			<xsl:variable name = "cellPrefix" select = "concat('hoursEntry-',$rowID,'-')"/>
			<xsl:variable name = "rowSpan">
				<xsl:choose>
					<xsl:when test = "Code[@CodeClass='Program']">2</xsl:when>
					<xsl:otherwise>1</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<xsl:call-template name = "makeDayCell">
				<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
				<xsl:with-param name = "cellType" select = "'hoursEntry'"/>
				<xsl:with-param name = "thisDay" select = "'1'"/>
				<xsl:with-param name = "lastDay" select = "'7'"/>
				<xsl:with-param name = "theList" select = "ChargedTime[@DayIndex &lt; 8]"/>
				<xsl:with-param name = "rowSpan" select = "$rowSpan"/>
			</xsl:call-template>
			<td width = "3"/>
			<xsl:call-template name = "makeDayCell">
				<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
				<xsl:with-param name = "cellType" select = "'hoursEntry'"/>
				<xsl:with-param name = "thisDay" select = "'8'"/>
				<xsl:with-param name = "lastDay" select = "'14'"/>
				<xsl:with-param name = "theList" select = "ChargedTime[@DayIndex > 7]"/>
				<xsl:with-param name = "rowSpan" select = "$rowSpan"/>
			</xsl:call-template>
			<td width = "3"/>
			<xsl:variable name = "sumList">
				<xsl:call-template name = "makeSumList">
					<xsl:with-param name = "cellNameTemplate" select = "concat($cellPrefix,'%')"/>
					<xsl:with-param name = "firstItem" select = "'1'"/>
					<xsl:with-param name = "lastItem" select = "'14'"/>
				</xsl:call-template>
			</xsl:variable>
			<td align = "right" rowspan = "{$rowSpan}">
				<x:calc id = "{$cellPrefix}PP-Calc" digits = "2" term = "{normalize-space(substring-after($sumList,'+'))}">
					<x:textoutput id = "{$cellPrefix}PP" send = "false"/>
				</x:calc>
			</td>
		</tr>
		<tr>                
			<td align = "left" colspan = "3">                        
				<xsl:apply-templates mode = "label" select = "Code[@CodeClass='Activity']"/>                
			</td>        
		</tr>
	</xsl:template>
	<xsl:template match = "Code" name = "Code" mode = "code">
		<xsl:if test = "@CodeClass='Program' or @CodeClass='LeaveUsed' or @CodeClass='AboveTour'">
			<xsl:value-of select = "@CodeClass" disable-output-escaping = "no"/>
		</xsl:if>
		<xsl:value-of select = "@Code" disable-output-escaping = "no"/>
	</xsl:template>
	<xsl:template match = "Code" name = "Code" mode = "label">
		<xsl:choose>
			<xsl:when test = "@CodeClass = 'Program'">
				<xsl:value-of select = "concat(@Abbreviation,'(',@Code,')')" disable-output-escaping = "no"/>
			</xsl:when>
			<xsl:when test = "@CodeClass =  'Activity'">
				<xsl:value-of select = "concat(' ',@Abbreviation,'(',@Code,')')" disable-output-escaping = "no"/>
			</xsl:when>
			<xsl:when test = "@CodeClass = 'LeaveUsed'">
				<xsl:value-of select = "concat(@Name,'(','Balance',')')" disable-output-escaping = "no"/>        
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select = "concat(@Name)" disable-output-escaping = "no"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name = "makeDayCell">
		<xsl:param name = "cellType"/>
		<xsl:param name = "cellPrefix"/>
		<xsl:param name = "theList"/>
		<xsl:param name = "thisDay"/>
		<xsl:param name = "lastDay"/>
		<xsl:param name = "rowSpan"/>
		<xsl:if test = "$theList or ($thisDay &lt;= $lastDay)">
			<xsl:variable name = "cellTag" select = "concat($cellPrefix,$thisDay)"/>
			<xsl:choose>
				<xsl:when test = "$thisDay = $theList[1]/@DayIndex">
					<td align = "right" rowspan = "{$rowSpan}">
						<!--						<xsl:value-of select = "'Make Cell from list!'" disable-output-escaping = "no"/>
						<xsl:value-of select = "concat($cellTag,':',$cellType,':',$thisDay,':',$lastDay)" disable-output-escaping = "no"/>
						<xsl:copy-of select = "$theList" disable-output-escaping = "no"/>
						<xsl:value-of select = "'Recursive call with rest of the list'" disable-output-escaping = "no"/>
-->
						<xsl:choose>
							<xsl:when test = "$cellType = 'hoursEntry'">
								<x:textinput id = "{$cellTag}" send = "true" ctype = "num" validation = "strict" value = "{$theList[1]/@Hours}"/>
							</xsl:when>
							<xsl:when test = "$cellType = 'scheduledHours'">
								<x:textoutput id = "{$cellTag}" send = "false" value = "{$theList[1]/@Hours}"/>
							</xsl:when>
							<xsl:when test = "$cellType = 'SStart'">
								<x:textoutput id = "{$cellTag}" send = "false" value = "{$theList[1]/@Start}"/>
							</xsl:when>
							<xsl:when test = "$cellType = 'SStop'">
								<x:textoutput id = "{$cellTag}" send = "false" value = "{$theList[1]/@Stop}"/>
							</xsl:when>
							<xsl:when test = "$cellType = 'SLunch'">
								<x:textoutput id = "{$cellTag}" send = "false" value = "{$theList[1]/@Lunch}"/>
							</xsl:when>
							<xsl:when test = "$cellType = 'LStart' or $cellType = 'AStart'">
								<x:textinput id = "{$cellTag}" send = "true" value = "{$theList[1]/@Start}"/>
							</xsl:when>
							<xsl:when test = "$cellType = 'LStop' or $cellType = 'AStop'">
								<x:textinput id = "{$cellTag}" send = "true" value = "{$theList[1]/@Stop}"/>
							</xsl:when>
							<xsl:when test = "$cellType = 'ALunch'">
								<x:textinput id = "{$cellTag}" send = "true" ctype = "num" validation = "strict" value = "{$theList[1]/@Lunch}"/>
							</xsl:when>
						</xsl:choose>
					</td>
					<xsl:call-template name = "makeDayCell">
						<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
						<xsl:with-param name = "cellType" select = "$cellType"/>
						<xsl:with-param name = "thisDay" select = "$thisDay + 1"/>
						<xsl:with-param name = "lastDay" select = "$lastDay"/>
						<xsl:with-param name = "theList" select = "$theList[position()!=1]"/>
						<xsl:with-param name = "rowSpan" select = "$rowSpan"/>
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<td align = "right" rowspan = "{$rowSpan}">
						<!--						<xsl:value-of select = "'Make default Cell!'" disable-output-escaping = "no"/>
						<xsl:value-of select = "concat($cellTag,':',$cellType,':',$thisDay,':',$lastDay)" disable-output-escaping = "no"/>
						<xsl:copy-of select = "$theList" disable-output-escaping = "no"/>
						<xsl:value-of select = "'Recursive call with same list'" disable-output-escaping = "no"/>
-->
						<xsl:choose>
							<xsl:when test = "$cellType = 'hoursEntry'">
								<x:textinput id = "{$cellTag}" send = "true" ctype = "num" validation = "strict" value = "0.00"/>
							</xsl:when>
							<xsl:when test = "$cellType = 'scheduledHours'">
								<x:textoutput id = "{$cellTag}" send = "false" value = "0.00"/>
							</xsl:when>
							<xsl:when test = "$cellType = 'SStart' or $cellType = 'SStop' or $cellType='SLunch'">
								<x:textoutput id = "{$cellTag}" send = "false" value = "----"/>
							</xsl:when>
							<xsl:when test = "$cellType = 'LStart' or $cellType = 'LStop' or $cellType = 'AStart' or $cellType = 'AStop'">
								<x:textinput id = "{$cellTag}" send = "true" value = ""/>
							</xsl:when>
							<xsl:when test = "$cellType='ALunch'">
								<x:textinput id = "{$cellTag}" send = "true" ctype = "num" validation = "strict" value = ""/>
							</xsl:when>
						</xsl:choose>
					</td>
					<xsl:call-template name = "makeDayCell">
						<xsl:with-param name = "cellPrefix" select = "$cellPrefix"/>
						<xsl:with-param name = "cellType" select = "$cellType"/>
						<xsl:with-param name = "thisDay" select = "$thisDay + 1"/>
						<xsl:with-param name = "lastDay" select = "$lastDay"/>
						<xsl:with-param name = "theList" select = "$theList"/>
						<xsl:with-param name = "rowSpan" select = "$rowSpan"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>
	<xsl:template match = "Note">
		<x:tg id = "Note">
			<xsl:call-template name = "HeadingA">
				<xsl:with-param name = "cell2" select = "'Note to Timekeeper'"/>
			</xsl:call-template>
			<table border = "1" frame = "box" rules = "all" width = "100%">
				<tbody>
					<tr>
						<td align = "center">
							<x:textarea id = "tknote" send = "true" rows = "5" cols = "51">
								<xsl:value-of select = "normalize-space(.)" disable-output-escaping = "no"/>
							</x:textarea>
						</td>
					</tr>
				</tbody>
			</table>
		</x:tg>
	</xsl:template>
	<xsl:template name = "HeadingA">
		<xsl:param name = "cell2"/>
		<xsl:param name = "cell3"/>
		<table border = "1" frame = "box" rules = "none" width = "100%">
			<tr>
				<td width = "40%">
					<xsl:value-of select = "//Employee/@Name" disable-output-escaping = "no"/>
				</td>
				<xsl:choose>
					<xsl:when test = "not($cell3)">
						<td align = "center" width = "30%">
							<xsl:value-of select = "$cell2" disable-output-escaping = "no"/>
						</td>
					</xsl:when>
					<xsl:otherwise>
						<td align = "center">
							<xsl:value-of select = "$cell2" disable-output-escaping = "no"/>
						</td>
						<td align = "center">
							<xsl:value-of select = "$cell3" disable-output-escaping = "no"/>
						</td>
					</xsl:otherwise>
				</xsl:choose>
				<td align = "right">Pay Period <xsl:value-of select = "//PayPeriod/@Number" disable-output-escaping = "no"/>
				</td>
				<td align = "left">
					<xsl:variable name = "startMonth">
						<xsl:call-template name = "monthFormat">
							<xsl:with-param name = "month" select = "//PayPeriod/PayPeriodDay[@DayIndex = 1]/@Month"/>
						</xsl:call-template>
					</xsl:variable>
					<xsl:variable name = "endMonth">
						<xsl:call-template name = "monthFormat">
							<xsl:with-param name = "month" select = "//PayPeriod/PayPeriodDay[@DayIndex = 14]/@Month"/>
						</xsl:call-template>
					</xsl:variable>
					<xsl:value-of select = "concat($startMonth,' ',            //PayPeriod/PayPeriodDay[@DayIndex = 1]/@Day,', ',           //PayPeriod/PayPeriodDay[@DayIndex = 1]/@Year,' - ',           $endMonth,' ',           //PayPeriod/PayPeriodDay[@DayIndex = 14]/@Day,', ',           //PayPeriod/PayPeriodDay[@DayIndex = 14]/@Year)" disable-output-escaping = "no"/>
				</td>
			</tr>
		</table>
	</xsl:template>
	<xsl:template name = "monthFormat">
		<xsl:param name = "month"/>
		<xsl:choose>
			<xsl:when test = "$month = 1">Jan.</xsl:when>
			<xsl:when test = "$month = 2">Feb.</xsl:when>
			<xsl:when test = "$month = 3">Mar.</xsl:when>
			<xsl:when test = "$month = 4">Apr.</xsl:when>
			<xsl:when test = "$month = 5">May</xsl:when>
			<xsl:when test = "$month = 6">Jun.</xsl:when>
			<xsl:when test = "$month = 7">Jul.</xsl:when>
			<xsl:when test = "$month = 8">Aug.</xsl:when>
			<xsl:when test = "$month = 9">Sep.</xsl:when>
			<xsl:when test = "$month = 10">Oct.</xsl:when>
			<xsl:when test = "$month = 11">Nov.</xsl:when>
			<xsl:when test = "$month = 12">Dec.</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template name = "dayHeading">
		<xsl:param name = "beginDay"/>
		<xsl:param name = "endDay"/>
		<xsl:if test = "$beginDay &lt;= $endDay">
			<xsl:choose>
				<xsl:when test = "($beginDay mod 7) = 1">
					<td align = "center">Sun <xsl:value-of select = "//*/PayPeriodDay[@DayIndex = $beginDay]/@Day" disable-output-escaping = "no"/>
					</td>
				</xsl:when>
				<xsl:when test = "($beginDay mod 7) = 2">
					<td align = "center">M <xsl:value-of select = "//*/PayPeriodDay[@DayIndex = $beginDay]/@Day" disable-output-escaping = "no"/>
					</td>
				</xsl:when>
				<xsl:when test = "($beginDay mod 7) = 3">
					<td align = "center">T <xsl:value-of select = "//*/PayPeriodDay[@DayIndex = $beginDay]/@Day" disable-output-escaping = "no"/>
					</td>
				</xsl:when>
				<xsl:when test = "($beginDay mod 7) = 4">
					<td align = "center">W <xsl:value-of select = "//*/PayPeriodDay[@DayIndex = $beginDay]/@Day" disable-output-escaping = "no"/>
					</td>
				</xsl:when>
				<xsl:when test = "($beginDay mod 7) = 5">
					<td align = "center">T <xsl:value-of select = "//*/PayPeriodDay[@DayIndex = $beginDay]/@Day" disable-output-escaping = "no"/>
					</td>
				</xsl:when>
				<xsl:when test = "($beginDay mod 7) = 6">
					<td align = "center">F <xsl:value-of select = "//*/PayPeriodDay[@DayIndex = $beginDay]/@Day" disable-output-escaping = "no"/>
					</td>
				</xsl:when>
				<xsl:when test = "($beginDay mod 7) = 0">
					<td align = "center">Sat <xsl:value-of select = "//*/PayPeriodDay[@DayIndex = $beginDay]/@Day" disable-output-escaping = "no"/>
					</td>
				</xsl:when>
			</xsl:choose>
			<xsl:call-template name = "dayHeading">
				<xsl:with-param name = "beginDay" select = "$beginDay + 1"/>
				<xsl:with-param name = "endDay" select = "$endDay"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	<xsl:template name = "catHeading">
		<xsl:param name = "title"/>
		<xsl:param name = "listName"/>        
		<tr>
			<td align = "left" width = "20%">
				<p>
					<xsl:value-of select = "$title" disable-output-escaping = "no"/>
				</p>
			</td>
			<xsl:choose>
				<xsl:when test = "$listName">
					<td align = "center" width = "3%" colspan = "2">
						<p>
							<acronym title = "Add/Delete {$listName}">+/-</acronym>
						</p>
					</td>
					<td colspan = "17"/>
				</xsl:when>
				<xsl:otherwise>
					<td colspan = "19"/>
				</xsl:otherwise>
			</xsl:choose>
		</tr>
	</xsl:template>
	<xsl:template name = "makeSumList">
		<xsl:param name = "cellNameTemplate"/>
		<xsl:param name = "firstItem"/>
		<xsl:param name = "lastItem"/>
		<xsl:if test = "$firstItem &lt;= $lastItem">
			<xsl:value-of select = "concat(' + ',substring-before($cellNameTemplate,'%'),$firstItem,substring-after($cellNameTemplate,'%'))" disable-output-escaping = "no"/>
			<xsl:call-template name = "makeSumList">
				<xsl:with-param name = "cellNameTemplate" select = "$cellNameTemplate"/>
				<xsl:with-param name = "firstItem" select = "$firstItem + 1"/>
				<xsl:with-param name = "lastItem" select = "$lastItem"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>