<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  version="1.0">
  <xsl:output method="html" />

  <xsl:param name="t" select="ProductInfo/Request/Args/Arg[@name = 't']/@value" />

  <xsl:template match="/">

    <html>
      <head>
	<meta http-equiv="Content-Script-Type" content="text/javascript" />
	<meta http-equiv="Content-Style-Type" content="text/css" />
	<style type="text/css">
	  * { margin: 0px; padding:}
	  .best_seller { border: 1px solid black; width: 748px; text-align: center; background-color: #FFF;}
	  .ads { font-size: 9pt; margin-bottom: 3px; padding: 0px 2px; text-align: right; color: #FFF; background-color: black;}
	  img { border: none; }
	  img.s_img { margin: 1px; }
	</style>
        <title>Amazon</title>
      </head>
      <body>
	<div class="best_seller">
	  <p class="ads">Amazon Ads</p>
          <table border = "0"><tr>
	  <xsl:apply-templates select="ProductInfo/Details">
	    <xsl:sort select="SalesRank" order="ascending"/>
	  </xsl:apply-templates>
          </tr></table>
	</div>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="Details">
    <td>
      <xsl:choose>
	<xsl:when test="(position() = 1)">
	  <xsl:element name="a">
	    <xsl:attribute name="href">http://www.amazon.co.jp/exec/obidos/ASIN/<xsl:value-of select="Asin"/>/<xsl:value-of select="$t"/>/ref=nosim</xsl:attribute>
	    <xsl:attribute name="title"><xsl:value-of select="ProductName" />
	      <xsl:if test="Catalog='Music'">
		<xsl:text> / </xsl:text><xsl:value-of select="Artists/Artist" />
	      </xsl:if>
	    </xsl:attribute>
	    <xsl:attribute name="target">_top</xsl:attribute>
	    <img src="{ImageUrlMedium}"><xsl:attribute name="onload">if (this.width=='1' &amp;&amp; this.src.match(/\.01\./)) { this.src='http://finder-web.net/blog/amazon/noimage_m.gif'; } else if (this.width=='1') { this.src=this.src.replace('.09.','.01.'); }</xsl:attribute></img>
	  </xsl:element>

	</xsl:when>
	<xsl:otherwise>
	  <xsl:element name="a">
	    <xsl:attribute name="href">http://www.amazon.co.jp/exec/obidos/ASIN/<xsl:value-of select="Asin"/>/<xsl:value-of select="$t"/>/ref=nosim</xsl:attribute>
	    <xsl:attribute name="title"><xsl:value-of select="ProductName" />
	      <xsl:if test="Catalog='Music'">
		<xsl:text> / </xsl:text><xsl:value-of select="Artists/Artist" />
	      </xsl:if>
	    </xsl:attribute>
	    <xsl:attribute name="target">_top</xsl:attribute>
	    <img src="{ImageUrlSmall}" class="s_img"><xsl:attribute name="onload">if (this.width=='1' &amp;&amp; this.src.match(/\.01\./)) { this.src='http://finder-web.net/blog/amazon/noimage_s.gif'; } else if (this.width=='1') { this.src=this.src.replace('.09.','.01.'); }</xsl:attribute></img>
	  </xsl:element>
	</xsl:otherwise>
       </xsl:choose>
    </td>
  </xsl:template>
</xsl:stylesheet>

