<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:template match="/"><xsl:apply-templates select="//Series[SeriesInstanceUid='']"/></xsl:template>
	<xsl:template match="Series">
		<table width="100%" height="100%" cellpadding="5" cellspacing="0" border="0" style="table-layout:fixed; width:100%; height:100%;">
			<xsl:call-template name="tabularRow">
				<xsl:with-param name="tmpCntC">1</xsl:with-param>
				<xsl:with-param name="tmpCntR">0</xsl:with-param>
				<xsl:with-param name="varROW"><xsl:value-of select="../Layout/@Row"/></xsl:with-param>
				<xsl:with-param name="varCOL"><xsl:value-of select="../Layout/@Col"/></xsl:with-param>
			</xsl:call-template>
		</table>
	</xsl:template>
	<xsl:template name="tabularRow">
		<xsl:param name="tmpCntC"/>
		<xsl:param name="tmpCntR"/>
		<xsl:param name="varROW"/>
		<xsl:param name="varCOL"/>
		<xsl:if test="number($tmpCntR) &lt; number($varROW)">
			<tr>
				<xsl:call-template name="tabularCell">
					<xsl:with-param name="tmpCntC"><xsl:value-of select="$tmpCntC"/></xsl:with-param>
					<xsl:with-param name="tmpCntR"><xsl:value-of select="$tmpCntR"/></xsl:with-param>
					<xsl:with-param name="varROW"><xsl:value-of select="$varROW"/></xsl:with-param>
					<xsl:with-param name="varCOL"><xsl:value-of select="$varCOL"/></xsl:with-param>
				</xsl:call-template>
			</tr>
			<xsl:call-template name="tabularRow">
				<xsl:with-param name="tmpCntC">1</xsl:with-param>
				<xsl:with-param name="tmpCntR"><xsl:value-of select="number($tmpCntR + 1)"/></xsl:with-param>
				<xsl:with-param name="varROW"><xsl:value-of select="$varROW"/></xsl:with-param>
				<xsl:with-param name="varCOL"><xsl:value-of select="$varCOL"/></xsl:with-param>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	<xsl:template name="tabularCell">
		<xsl:param name="tmpCntC"/>
		<xsl:param name="tmpCntR"/>
		<xsl:param name="varROW"/>
		<xsl:param name="varCOL"/>
		<xsl:if test="number($tmpCntC) &lt;= number($varCOL)">
				<xsl:variable name="varImgCnt"><xsl:value-of select="number($tmpCntR) * number($varCOL) + number($tmpCntC)"/></xsl:variable>
				<td align="center" valign="top" class="use">
					<xsl:attribute name="id">cell_<xsl:value-of select="$varImgCnt"/></xsl:attribute>
					<xsl:attribute name="name">cell_<xsl:value-of select="$varImgCnt"/></xsl:attribute>
					<xsl:attribute name="width"><xsl:value-of select="100 div number($varCOL)"/>%</xsl:attribute>
					<xsl:attribute name="height"><xsl:value-of select="100 div number($varROW)"/>%</xsl:attribute>
					<center>
						<xsl:element name="img">
							<xsl:attribute name="id">img_<xsl:value-of select="$varImgCnt"/></xsl:attribute>
							<xsl:attribute name="name">img_<xsl:value-of select="$varImgCnt"/></xsl:attribute>
						<xsl:choose>
						<xsl:when test="number($varROW) = 2 and number($varCOL) = 3">
							<xsl:attribute name="width">100%</xsl:attribute>
						</xsl:when>
						<xsl:otherwise>
							<xsl:attribute name="height">100%</xsl:attribute>
						</xsl:otherwise>
						</xsl:choose>
							<xsl:attribute name="style">display:none;cursor:hand;</xsl:attribute>
							<xsl:attribute name="onclick">viewImage(this)</xsl:attribute>
						</xsl:element>
					</center>
				</td>
				<xsl:call-template name="tabularCell">
					<xsl:with-param name="tmpCntC"><xsl:value-of select="number($tmpCntC + 1)"/></xsl:with-param>
					<xsl:with-param name="tmpCntR"><xsl:value-of select="$tmpCntR"/></xsl:with-param>
					<xsl:with-param name="varROW"><xsl:value-of select="$varROW"/></xsl:with-param>
					<xsl:with-param name="varCOL"><xsl:value-of select="$varCOL"/></xsl:with-param>
				</xsl:call-template>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>