<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:template match="/">
		<table cellpadding="0" cellspacing="0" border="0" style="table-layout:fixed;">
			<xsl:choose>
				<xsl:when test="count(*) = 0 or count(IHE_PDI/*) = 0">
				<tr>
					<td colspan="19" align="center" valign="middle" height="100" >
					no result(s)
					</td>
				</tr>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates select="IHE_PDI/Study"/>
				</xsl:otherwise>
			</xsl:choose>	
		</table>
	</xsl:template>

	<xsl:template match="Study">
				<xsl:variable name="varStudy"><xsl:value-of select="position()"/></xsl:variable>
					<xsl:element name="tr">
						<xsl:if test="position() mod 2 = 0">
							<xsl:attribute name="bgcolor">FFFFFF</xsl:attribute>
							<xsl:attribute name="prebgcolor">FFFFFF</xsl:attribute>
						</xsl:if>
						<xsl:if test="position() mod 2 = 1">
							<xsl:attribute name="bgcolor">F1F1F1</xsl:attribute>
							<xsl:attribute name="prebgcolor">F1F1F1</xsl:attribute>
						</xsl:if>
						<xsl:attribute name="style">cursor:hand;</xsl:attribute>
						<xsl:attribute name="onMouseOver">mouseOverRow(this)</xsl:attribute>
						<xsl:attribute name="onMouseOut">mouseOutRow(this)</xsl:attribute>
						<xsl:attribute name="onClick">mouseClickRow(this)</xsl:attribute>
						<xsl:attribute name="value"><xsl:value-of select="StudyInstanceUid"/></xsl:attribute>
						<xsl:attribute name="description">
							<xsl:value-of select="PatientName"/> / <xsl:value-of select="PatientId"/> / <xsl:value-of select="PatientSex"/> / <xsl:value-of select="PatientAge"/> / <xsl:value-of select="BirthDate"/> / <xsl:value-of select="StudyDttm"/> / <xsl:value-of select="Modality"/> / <xsl:value-of select="Bodypart"/>
						</xsl:attribute>
						<td width="1" bgcolor="#E7EFFC" height="22" align="center"><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="20" height="24" align="center" >
							<xsl:element name="a">
								<xsl:attribute name="href">javascript:fold_tree('O_<xsl:value-of select="$varStudy"/>', 0)</xsl:attribute>
								<xsl:element name="img">
									<xsl:attribute name="src">./DATA/MNU_PLUS.GIF</xsl:attribute>
									<xsl:attribute name="border">0</xsl:attribute>
									<xsl:attribute name="width">10</xsl:attribute>
									<xsl:attribute name="id">TIO_<xsl:value-of select="$varStudy"/></xsl:attribute>
								</xsl:element>
							</xsl:element>
						</td>
						<td width="1" bgcolor="#F1F1F1" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="100" align="left" >
							<xsl:attribute name="title"><xsl:value-of select="PatientName"/></xsl:attribute>
							<xsl:choose>
								<xsl:when test="Report = 'Read'"><font color="#4169E1" size="-4">[R] </font></xsl:when>
								<xsl:when test="Report = 'Unread'"><font color="#4169E1" size="-4">[U] </font></xsl:when>
							</xsl:choose>
							<xsl:value-of select="PatientName"/>
						</td>
						<td width="1" bgcolor="#F1F1F1" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="60" align="left" >
							<xsl:attribute name="title"><xsl:value-of select="PatientId"/></xsl:attribute>
							<xsl:value-of select="PatientId"/>
						</td>
						<td width="1" bgcolor="#F1F1F1" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="30" align="center">
							<xsl:attribute name="title"><xsl:value-of select="PatientSex"/></xsl:attribute>
							<xsl:value-of select="PatientSex"/>
						</td>
						<td width="1" bgcolor="#F1F1F1" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="40" align="center">
							<xsl:attribute name="title"><xsl:value-of select="PatientAge"/></xsl:attribute>
							<xsl:value-of select="PatientAge"/>
						</td>
<!-- DOB					<td width="1" bgcolor="#F1F1F1" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="40" align="center">
							<xsl:attribute name="title"><xsl:value-of select="BirthDate"/></xsl:attribute>
							<xsl:value-of select="BirthDate"/>
						</td>
-->						
						<td width="1" bgcolor="#F1F1F1" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="80" align="center">
							<xsl:attribute name="title"><xsl:value-of select="StudyDesc"/></xsl:attribute>
							<xsl:value-of select="StudyDesc"/>
						</td>
						<td width="1" bgcolor="#F1F1F1" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="80" align="center">
							<xsl:attribute name="title"><xsl:value-of select="StudyDttm"/></xsl:attribute>
							<xsl:value-of select="StudyDttm"/>
						</td>
						<td width="1" bgcolor="#F1F1F1" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="40" align="center">
							<xsl:attribute name="title"><xsl:value-of select="Modality"/></xsl:attribute>
							<xsl:value-of select="Modality"/>
						</td>
						<td width="1" bgcolor="#F1F1F1" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td align="center">
							<xsl:attribute name="title"><xsl:value-of select="Bodypart"/></xsl:attribute>
							<xsl:value-of select="Bodypart"/>
						</td>
						<td width="1" bgcolor="#F1F1F1" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>

					</xsl:element>
					
					<xsl:element name="tr">
						<xsl:attribute name="style">display:none;</xsl:attribute>
						<xsl:attribute name="id">O_<xsl:value-of select="position()"/></xsl:attribute>
						<td colspan="2">&#160;</td>
						<td colspan="17" align="right">
							<table width="100%" border="0" cellpadding="1" cellspacing="0" bgcolor="gray">
								<tr> 
									<td valign="top"> 
										<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="white">
											<xsl:call-template name="SERIES_HEADER"/>
											<xsl:apply-templates select="Series"/>
										</table>
									
									</td>
								</tr>
							</table>
						</td>
					</xsl:element>
	</xsl:template>


	<xsl:template match="Series">
			<xsl:variable name="varStudy"><xsl:value-of select="../AccessionNumber"/></xsl:variable>
			<xsl:variable name="varSeries"><xsl:value-of select="SeriesInstanceUid"/></xsl:variable>

					<xsl:element name="tr">
						<xsl:if test="position() mod 2 = 0">
							<xsl:attribute name="bgcolor">FFFFFF</xsl:attribute>
						</xsl:if>
						<xsl:if test="position() mod 2 = 1">
							<xsl:attribute name="bgcolor">F1F1F1</xsl:attribute>
						</xsl:if>
						<xsl:attribute name="style">cursor:hand;</xsl:attribute>
						<xsl:attribute name="onMouseOver">mouseOverRow(this)</xsl:attribute>
						<xsl:attribute name="onMouseOut">mouseOutRow(this)</xsl:attribute>
						<td width="30" height="22" align="center">
							<xsl:element name="input">
								<xsl:attribute name="type">CHECKBOX</xsl:attribute>
								<xsl:attribute name="id">chkSelect</xsl:attribute>
								<xsl:attribute name="name">chkSelect</xsl:attribute>
								<xsl:attribute name="value"><xsl:value-of select="SeriesInstanceUid"/></xsl:attribute>
								<xsl:attribute name="onclick">clickCheckBox(this)</xsl:attribute>
							</xsl:element>
						</td>
		        		<td width="1" bgcolor="#ffffff" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td align="left">
							<xsl:value-of select="SeriesDesc"/>
						</td>
			    		<td width="1" bgcolor="#ffffff" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="60" align="center">
							<xsl:value-of select="Modality"/>
						</td>
						<td width="1" bgcolor="#ffffff" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="60" align="center">
							<xsl:value-of select="BodyPart"/>
						</td>
						<td width="1" bgcolor="#ffffff" height="22" align="center" ><img src="./DATA/TR.GIF" width="1" height="20"/></td>
						<td width="40" align="center">
							<xsl:value-of select="count(Image)"/>
						</td>
					</xsl:element>
	</xsl:template>


	<xsl:template name="SERIES_HEADER">
				<tr>
					<td width="30" align="center" background="./DATA/L_T.GIF"/>
					<td width="1" align="center" background="./DATA/L_T.GIF" class="use"><img src="./DATA/TB_LINE.GIF" width="1" height="30"/></td>
					<td align="center" background="./DATA/L_T.GIF" class="use"><a href="#" class="titlebar"><strong>SeriesDesc</strong></a></td>
					<td width="1" align="center" background="./DATA/L_T.GIF" class="use"><img src="./DATA/TB_LINE.GIF" width="1" height="30"/></td>
					<td width="60" align="center" background="./DATA/L_T.GIF" class="use"><a href="#" class="titlebar"><strong>Mdl</strong></a></td>
					<td width="1" align="center" background="./DATA/L_T.GIF" class="use"><img src="./DATA/TB_LINE.GIF" width="1" height="30"/></td>
					<td width="60" align="center" background="./DATA/L_T.GIF" class="use"><a href="#" class="titlebar"><strong>Body</strong></a></td>
					<td width="1" align="center" background="./DATA/L_T.GIF" class="use"><img src="./DATA/TB_LINE.GIF" width="1" height="30"/></td>
					<td width="40" align="center" background="./DATA/L_T.GIF" class="use"><a href="#" class="titlebar"><strong>Cnt</strong></a></td>
				</tr>
	</xsl:template>


</xsl:stylesheet>
