<?xml version="1.0" encoding="US-ASCII"?>
<!-- This stylesheet displays the contents of any valid XBRL instance that uses 'h' tags.
Copyright (C) 2006 Standard Advantage (walter@hamscher.com)

This stylesheet is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY 
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License 
(http://opensource.org/licenses/gpl-license) for more details.
-->
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
   xmlns:xbrli='http://www.xbrl.org/2003/instance'
   xmlns:h="http://StandardAdvantage.com/h" 
   xmlns:xlink="http://www.w3.org/1999/xlink"
   >

	<!-- Because it is written in XSL version 1.0 which is not namespace-aware, it only works when the namespace has prefix 'h'. -->
	<xsl:output doctype-public="-//W3C//DTD HTML 4.01//EN" encoding="US-ASCII" omit-xml-declaration="yes" indent="yes"/>
	<xsl:template match="/">
		<html>
			<head>
				<title/>
			</head>
			<body bgcolor="#E0E0D0">
				<xsl:apply-templates select="node()|@*"/>
			</body>
		</html>
	</xsl:template>
	<!-- main node matches -->
	<xsl:template match="h:txt" mode="td">
		<xsl:element name="div">
			<xsl:apply-templates select="@*"/>
			<xsl:value-of select="*"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="h:table">
		<xsl:element name="{local-name()}">
			<xsl:apply-templates select="@*"/>
			<xsl:attribute name="width">800</xsl:attribute>
			<xsl:apply-templates select="*" mode="table"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="h:tr" mode="table">
		<xsl:element name="{local-name()}">
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates select="*" mode="tr"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="h:td|h:th" mode="tr">
		<xsl:element name="{local-name()}">
			<xsl:apply-templates select="@*"/>
			<xsl:if test="count(*)=1 and count(*[@unitRef])=1">
				<!-- This needs to be at cell level since the number might be embedded in text. -->
				<xsl:attribute name="nowrap">nowrap</xsl:attribute>
				<!-- xsl:attribute name="align">right</xsl:attribute -->
			</xsl:if>
			<xsl:apply-templates select="*" mode="td"/>
		</xsl:element>
	</xsl:template>
	<!-- nested table inside a td -->
	<xsl:template match="h:table" mode="td">
		<xsl:apply-templates select="."/>
	</xsl:template>
	<!--default node matches -->
	<xsl:template match="*[local-name()='context' or local-name()='schemaRef' or local-name()='unit']"/>
	<xsl:template match="node()[@contextRef ]" mode="table">
		<xsl:element name="tr">
			<xsl:apply-templates select="." mode="tr"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="node()[@contextRef ]" mode="tr">
		<xsl:element name="td">
			<xsl:attribute name="colspan">0</xsl:attribute>
			<xsl:attribute name="valign">bottom</xsl:attribute>
			<xsl:apply-templates select="." mode="td"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="node()[@contextRef]" mode="td">
		<xsl:element name="span">
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates select="text()"/>
		</xsl:element>
	</xsl:template>
	<!-- item appears at top level, use dumb default rendering -->
	<xsl:template match="*[@contextRef or @xlink:type='resource']">
		<table>
			<tr>
				<td width="400" align="left">
					<xsl:apply-templates select="." mode="td"/>
				</td>
				<td width="400" align="left" style="font-size: 9pt; font-style: italic">
					<xsl:value-of select="local-name()"/>&#160;[<xsl:value-of select="@contextRef"/>]</td>
			</tr>
		</table>
	</xsl:template>
	<!-- main attribute matches - all attribute templates are mode free -->
	<xsl:template match="@h:style|@h:align|@h:valign|@h:colspan|@h:rowspan|@h:border|@h:bgcolor">
		<xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
	</xsl:template>
	<!-- other attribute matches -->
	<xsl:template match="@*"/>
</xsl:stylesheet>

