<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- XSL for iTunes  -->
<xsl:output method="html" />
<xsl:template match="text()" />
<xsl:template match="plist/dict/dict[preceding-sibling::key[text() = 'Tracks']]">
<HTML>
<HEAD>
<META http-equiv="pragma" content="no-cache" />
<META http-equiv="imagetoolbar" content="no" />
   <style>
body { background-color: white; color: black; font-family: MS Sans Serif; font-size: xx-small; }

table { background-color: #F0F0F0; border: 6 ridge #E2E3E1; }
table.dft { width: 100%; }
table.head_nb { width: 100%; background-color: #E8E8FF; color: #000070; border-style: none; }
table.headInfo_nb { width: 100%; background-color: #E8E8FF; color: #700070; border-style: none; }
table.nb { width: 100%; background-color: #FFFFFF; border-style: none; }
table.pop { width: 100%; border: 3 ridge #E2E3E1; }

td { font-family: MS Sans Serif; vertical-align: middle; font-weight: bold; font-size: xx-small; border-style: none; }
td.data { text-align: left; background-color: white; color: black; border-top: 1 solid black; border-left: 1 solid black; }

th { background-color: #E8E8FF; color: black; font-family: MS Sans Serif; font-size: xx-small; border-top: 1 solid black; border-left: 1 solid black; }
th.header { background-color: #F0F0F0; color: #282898; border-top: 1 solid black; border-left: 1 solid black;}
   </style>
   
   <TITLE>Forest's iTunes List</TITLE>
</HEAD>
<BODY oncontextmenu='return false'>
   <center><table class="head_nb"><tr><th class="header">Forest's iTunes List</th></tr></table></center>
   <table width="100%">
	<tr>
	   <th type="header">Artist</th>
	   <th type="header">Name</th>
	   <th type="header">Album</th>
	   <th type="header">Genre</th>
	   <th type="header">Rating</th>
	   <th type="header">Length (mm:ss)</th>
	   <th type="header">Play Count</th>
	</tr>
	<xsl:apply-templates select="dict" mode="display">
	   <xsl:sort select="key[. = 'Artist']/following-sibling::*/text()" />
	</xsl:apply-templates>
   </table>
   <p align="center"><a href="http://www.eastcoastgames.com"><b>HOME</b></a></p>
   
   <!-- Begin Amazon Honor System Paybox -->
   <center>
   <img src="http://s1.amazon.com/exec/varzea/tipbox/A3VYL3CC3AKZKL/T14HZHHLW5GZGL" usemap="#T14HZHHLW5GZGL" border="0" alt="Amazon Honor System" />
   <map name="T14HZHHLW5GZGL">
   <area coords="350,0,460,60" href="http://s1.amazon.com/exec/varzea/pay/T14HZHHLW5GZGL" alt="Click Here to Pay" />
   <area coords="165,40,310,55" href="http://s1.amazon.com/exec/varzea/subst/fx/help/how-we-know.html" alt="Learn More" />
   </map></center>
<!-- End Amazon Honor System Paybox -->
</BODY>
</HTML>
</xsl:template>


<xsl:template match="dict" mode="display">
<tr>
	<xsl:choose>
		<xsl:when test="key[. = 'Artist']">
			<xsl:apply-templates select="key[. = 'Artist']" mode="display" />
		</xsl:when>
		<xsl:otherwise>
			<td><xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;</td>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:choose>
		<xsl:when test="key[. = 'Name']">
			<xsl:apply-templates select="key[. = 'Name']" mode="display" />
		</xsl:when>
		<xsl:otherwise>
			<td><xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;</td>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:choose>
		<xsl:when test="key[. = 'Album']">
			<xsl:apply-templates select="key[. = 'Album']" mode="display" />
		</xsl:when>
		<xsl:otherwise>
			<td><xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;</td>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:choose>
		<xsl:when test="key[. = 'Genre']">
			<xsl:apply-templates select="key[. = 'Genre']" mode="display" />
		</xsl:when>
		<xsl:otherwise>
			<td><xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;</td>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:choose>
		<xsl:when test="key[. = 'Rating']">
			<xsl:apply-templates select="key[. = 'Rating']" mode="display" />
		</xsl:when>
		<xsl:otherwise>
			<td><xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;</td>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:choose>
		<xsl:when test="key[. = 'Total Time']">
			<xsl:apply-templates select="key[. = 'Total Time']" mode="display" />
		</xsl:when>
		<xsl:otherwise>
			<td><xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;</td>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:choose>
		<xsl:when test="key[. = 'Play Count']">
			<xsl:apply-templates select="key[. = 'Play Count']" mode="display" />
		</xsl:when>
		<xsl:otherwise>
			<td><xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;</td>
		</xsl:otherwise>
	</xsl:choose>
</tr>
</xsl:template>

<xsl:template match="key" mode="display">
<td class="data">
<xsl:choose>
	<xsl:when test=". = 'Rating'">
		<xsl:if test="following-sibling::*/text()='100'">
			<img border='0' width='15' height='15' src='http://www.EastCoastGames.com/images/smile.gif' />
			<img border='0' width='15' height='15' src='http://www.EastCoastGames.com/images/smile.gif' />
			<img border='0' width='15' height='15' src='http://www.EastCoastGames.com/images/smile.gif' />
			<img border='0' width='15' height='15' src='http://www.EastCoastGames.com/images/smile.gif' />
			<img border='0' width='15' height='15' src='http://www.EastCoastGames.com/images/smile.gif' />
		</xsl:if>
		<xsl:if test="following-sibling::*/text()='80'">
			<img border='0' width='15' height='15' src="http://www.EastCoastGames.com/images/smile.gif" />
			<img border='0' width='15' height='15' src="http://www.EastCoastGames.com/images/smile.gif" />
			<img border='0' width='15' height='15' src="http://www.EastCoastGames.com/images/smile.gif" />
			<img border='0' width='15' height='15' src="http://www.EastCoastGames.com/images/smile.gif" />
		</xsl:if>
		<xsl:if test="following-sibling::*/text()='60'">
			<img border='0' width='15' height='15' src="http://www.EastCoastGames.com/images/smile.gif" />
			<img border='0' width='15' height='15' src="http://www.EastCoastGames.com/images/smile.gif" />
			<img border='0' width='15' height='15' src="http://www.EastCoastGames.com/images/smile.gif" />
		</xsl:if>
		<xsl:if test="following-sibling::*/text()='40'">
			<img border='0' width='15' height='15' src="http://www.EastCoastGames.com/images/smile.gif" />
			<img border='0' width='15' height='15' src="http://www.EastCoastGames.com/images/smile.gif" />
		</xsl:if>
		<xsl:if test="following-sibling::*/text()='20'">
			<img border='0' width='15' height='15' src="http://www.EastCoastGames.com/images/smile.gif" />
		</xsl:if>
	</xsl:when>
	<xsl:when test=". = 'Total Time'">
    <xsl:variable name="hours" select="following-sibling::*/text() div 1000 div 60 div 60" />
		<xsl:variable name="minutes" select="following-sibling::*/text() div 1000 div 60" />
		<xsl:variable name="seconds" select="format-number(following-sibling::*/text() div 1000 mod 60, '#')" />

		<xsl:value-of select="format-number(floor($minutes), '00')" />:<xsl:value-of select="format-number(floor($seconds), '00')" />
	</xsl:when>
	<xsl:otherwise>
		<xsl:value-of select="following-sibling::*/text()" />
	</xsl:otherwise>
</xsl:choose>
</td>
</xsl:template>
</xsl:stylesheet>
