<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd" />
<xsl:preserve-space elements="ReportLayout Section div a"/>

<xsl:param name="forScreen">no</xsl:param>
<xsl:param name="styleSheet"> // none passed</xsl:param>
<xsl:param name="javaScript"> // none passed </xsl:param>

<xsl:variable name="scrollingTableCounter">0</xsl:variable>

<xsl:template match="/">
	<html>
		<head>
		<!-- style sheet here-->
			<style>
				<xsl:value-of select="$styleSheet" disable-output-escaping="yes"/>
			</style>
			<script language="JavaScript">
			<xsl:text disable-output-escaping="yes">//&lt;![CDATA[</xsl:text>
				<xsl:value-of select="$javaScript" disable-output-escaping="yes"/>
			<xsl:text disable-output-escaping="yes">//]]&gt;</xsl:text>
			</script>
		</head>
		<body>
			<xsl:apply-templates/>
			<script>
			 if(typeof(initMyFuncs) != "undefined") { initMyFuncs(); }
			</script>
		</body>
	</html>
</xsl:template>
<xsl:template match="Stylesheet"/>
<xsl:template match="ReportLayout">
	<xsl:if test="$forScreen = false()">
		<div style="width: 100%; height: 47px; overflow: clip; background-color: #115577;"><img src="/webui/layout-images/report-banner-print.gif" style="height: 47px;"/></div>
	</xsl:if>
	<!-- div for the title -->
	<div style="margin-bottom: 15px;">
	<h1><xsl:value-of select="ReportTitle"/></h1>
	<h1><xsl:value-of select="ReportSubTitle"/></h1>
	<h1><xsl:text>time period: </xsl:text><xsl:value-of select="ReportInfo/@TimeRange"/></h1>
	<h1 style="color: red;"><xsl:value-of select="ReportInfo/@NoData" disable-output-escaping="yes"/></h1>
	</div>
	<xsl:apply-templates />

	<!-- table for the footer -->
<div class="sectionTitle"><xsl:text> </xsl:text></div>
<table class="description">
<thead>
<tr ><th colspan="2" align="left">Report Parameters:</th></tr>
</thead>
<tbody>
<tr><td><b>Report Name:</b></td><td><xsl:value-of select="ReportInfo/@Template"/></td></tr>
<tr><td><b>Instance Name:</b></td><td><xsl:value-of select="ReportInfo/@Instance"/></td></tr>
<tr><td><b>Report Run Time:</b></td><td><xsl:value-of select="ReportInfo/@RunTime"/></td></tr>
<tr><td><b>Time Period:</b></td><td><xsl:value-of select="ReportInfo/@TimeRange"/></td></tr>
<tr><td><b>Selections:</b></td><td><xsl:value-of select="ReportInfo/@Selections"/></td></tr>

</tbody>
</table>

</xsl:template>

<xsl:template match="ReportTitle"/>
<xsl:template match="ReportSubTitle"/>

<!-- Handle page layout attributes -->
<xsl:template match="Section">
	<div class="section"><xsl:apply-templates/></div>
</xsl:template>

<xsl:template match="SectionTitle">
	<!-- print the title -->
	<div class="sectionTitle">
		<span class="sectionTitle"><xsl:value-of select="."/></span>
	</div>
</xsl:template>

<!-- handle row layout and column layout -->
<xsl:template match="ColumnLayout">
	<table class="columnLayoutTable">
		<tr class="columnLayoutTable">
			<xsl:apply-templates/>
		</tr>
	</table>
</xsl:template>

<xsl:template match="Column">
	<td class="columnLayoutTable" valign="top">
		<xsl:if test="string(./@Width) != '' or string(./@Style) != ''">
			<xsl:attribute name="style"><!--
				--><xsl:if test="string(./@Width) != ''"><!--
					-->width: <xsl:value-of select="./@Width"/>px;<!--
				--></xsl:if><!--
				--><xsl:if test="string(./@Style) != ''"><!--
					--><xsl:value-of select="./@Style"/><!--
				--></xsl:if><!--
			--></xsl:attribute>
		</xsl:if>
		<xsl:apply-templates/>
	</td>
</xsl:template>

<xsl:template match="RowLayout/Row">
	<div class="rowLayoutRow">
		<xsl:if test="string(./@Style) != ''">
			<xsl:attribute name="style"><xsl:value-of select="./@Style"/></xsl:attribute>
		</xsl:if>
		<xsl:apply-templates/>
	</div>
</xsl:template>

<!-- handle drill link -->
<xsl:template match="DrillLink">
	<xsl:choose>
	<xsl:when test="$forScreen">
	<a target="_parent">
		<xsl:attribute name="href">
			<xsl:text>/webui/Reports/ReportRun/linkReport.do?</xsl:text>
			<xsl:for-each select="DrillProperty">
				<xsl:value-of select="./@Name"/>
				<xsl:text>=</xsl:text>
				<xsl:value-of select="./@Value"/>
				<xsl:text>&amp;</xsl:text>
			</xsl:for-each>
		</xsl:attribute>
		<xsl:value-of select="DrillText"/>
	</a>
	</xsl:when>
	<xsl:otherwise>
		<xsl:value-of select="DrillText"/>
	</xsl:otherwise>
	</xsl:choose>

</xsl:template>

<!-- handle table -->
<xsl:template match="table">
	<!-- correctly handle scrolling table -->
	<xsl:choose>
	<xsl:when test="./@scrolling = 'yes' and $forScreen and ./@scrollHeight != ''">

		<xsl:variable name="scrollingTableCounter"><xsl:value-of select="generate-id(.)"/></xsl:variable>
		<div>
			<xsl:attribute name="id">scrollingTable<xsl:value-of select="$scrollingTableCounter"/></xsl:attribute>
			<table class="dataTable"><xsl:apply-templates/></table>
		</div>
		<script language="JavaScript">
		xhtmlConfigureForScrolling(&quot;scrollingTable<xsl:value-of select="$scrollingTableCounter"/>&quot;,
			<xsl:value-of select="./@scrollHeight"/>,"100%");
		</script>
	</xsl:when>
	<xsl:otherwise>
		<table class="dataTable"><xsl:apply-templates/></table>
	</xsl:otherwise>
	</xsl:choose>
</xsl:template>


<xsl:template match="tr">
	<tr class="dataTable"><xsl:apply-templates /></tr>
</xsl:template>
<xsl:template match="td">
	<xsl:choose>
		<xsl:when test="./@Format = 'number'">
			<td class="dataTableNumber"><xsl:apply-templates /></td>
		</xsl:when>
		<xsl:when test="./@Format = 'noWrap'">
			<td class="dataTable" style="text-align: left;white-space: nowrap;"><xsl:apply-templates /></td>
		</xsl:when>
		<xsl:otherwise>
			<td class="dataTable"><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text><xsl:apply-templates /></td>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template match="th">
	<th class="dataTable"><xsl:apply-templates /></th>
</xsl:template>
<xsl:template match="thead">
	<thead class="dataTable"><xsl:apply-templates /></thead>
</xsl:template>

<xsl:template match="tfoot">
	<tfoot class="dataTable"><xsl:apply-templates /></tfoot>
</xsl:template>
<!-- handle graph -->
<xsl:template match="graph">
	<img>
		<xsl:attribute name="src"><xsl:value-of select="./@name"/>.<xsl:value-of select="./@type"/></xsl:attribute>
		<xsl:attribute name="style">width: <xsl:value-of select="./@width"/>px; height: <xsl:value-of select="./@height"/>px;</xsl:attribute>
		<xsl:attribute name="alt"><xsl:text>Graph: </xsl:text><xsl:value-of select="./@name"/></xsl:attribute>
		<xsl:attribute name="id"><xsl:text>annotatedTimeline</xsl:text><xsl:value-of select="./@name"/></xsl:attribute>
	</img>
	<div style="display: none;">
	      <xsl:attribute name="id">Annotate<xsl:value-of select="./@name"/></xsl:attribute>
	      <span><xsl:value-of select="./@AnnotationConfig"/></span>
	</div>
</xsl:template>

</xsl:stylesheet>

