<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name="Space"><xsl:text>&amp;nbsp;</xsl:text></xsl:variable>
<xsl:output method="html"/>

<xsl:template match="/">
	<html>
		<head>
			<link rel="STYLESHEET" href="css/main.css" type="text/css"/>
			<script type="text/javascript">
				function tabE(obj, e) 
				{
					var e = (typeof event != 'undefined') ? window.event : e; // IE : Moz 
					if (e.keyCode == 13) 
					{
						var ele = document.forms[0].elements;
						for (var i = 0; i &lt; ele.length; i++) 
						{
							var q = (i == ele.length - 1) ? 0 : i + 1; // if last element : if any other 
							if (obj == ele[i]) 
							{
								ele[q].focus();
								break
							}
						}
						return false;
					}
				}
				function submitForm() 
				{
				   // Get the first form with the name
				   // Usually the form name is not repeated
				   // but duplicate names are possible in HTML
				   // Therefore to work around the issue, enforce the correct index
				   var frm = document.getElementsByName('labelform')[0];
				   frm.submit(); // Submit the form
				   frm.reset();  // Reset all form data
				   document.getElementById("item").focus();
				   return false; // Prevent page refresh
				}
			</script>
		</head>
		<body>
			<xsl:apply-templates select="main_page"/>		
		</body>
	</html>
        
        
</xsl:template>


<!-- ======================================================================= -->

	<xsl:template match="main_page">
		<xsl:value-of select="@query_result"/>
		<xsl:apply-templates select="*[starts-with(name(), '_')]"/>		
	</xsl:template>

	<xsl:template match="_doc_mng">
		<div class="header_title">Documents</div>
		<p/>
		<form name="doc_form" method="post" action="{@doc_form_url}" enctype="multipart/form-data">
			<div class="group_label">Document Detail</div>
			<table class="items">
				<tr>
					<td class="input_label">Name</td>
					<td colspan="2"><input type="text" name="doc_name" id="doc_name" onkeypress="return tabE(this,event)" tabindex="1" value="{@doc_name}" required="y"/></td>
					<td></td>
				</tr>
				<tr>
					<td class="input_label">Type</td>
					<td>
						<select name="doc_type" id="doc_type" onkeypress="return tabE(this,event)" tabindex="5">
							<option value="Receipt">Receipt</option>
							<option value="Image">Image</option>
							<option value="Certificate">Certificate</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="input_label">File</td>
					<td colspan="2"><input type="file" name="doc_file" id="doc_file" onkeypress="return tabE(this,event)" tabindex="1" require="Y"/></td>
				</tr>
				<tr>
					<td>
						<input type="hidden" name="item_id" value="{@item_id}"/>
						<input type="hidden" name="item_hc_id" value="{@item_hc_id}"/>
						<input type="hidden" name="item_rl_id" value="{@item_rl_id}"/>
					</td>
					<td colspan="2">
						<button type="submit">Upload</button>
						<a href="{@doc_back_url}" class="back_button">Back</a>
					</td>
				</tr>
			</table>
		</form>
	</xsl:template>


	<xsl:template match="documents_xxx">
		<tr>
			<td class="doc_col">
				<a href="#" onclick="{@doc_url}"><img src="images/document-163-16.png"/><xsl:value-of select="@doc_name"/></a>
			</td>
			<td class="doc_col">			
				<xsl:value-of select="@doc_type"/>
			</td>
			<td class="doc_col">
				<a href="{@doc_del_url}"><img src="images/delete-137-48.png" height="16px" title="Delete"/></a>
			</td>
		</tr>
	</xsl:template>

</xsl:stylesheet>