<?xml version="1.0"?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:aws="http://xml.amazon.com/AWSECommerceService/2004-10-04"
  version="1.0">
  <xsl:output method="html" encoding="utf-8"/>

<xsl:template match="/">
	<html>
	<head>
	<title>amazon</title>
	<link>
		<xsl:attribute name="rel">stylesheet</xsl:attribute>
		<xsl:attribute name="type">text/css</xsl:attribute>
		<xsl:attribute name="charset">UTF-8</xsl:attribute>
		<xsl:attribute name="href">http://fuba.s7.xrea.com/nifuba.css</xsl:attribute>
	</link>
	</head>
	<body class="amazon_frame">
	<div class="amazon_mode">
	<h4>Amazon associate</h4>
	<form>
		<xsl:attribute name="target">_blank</xsl:attribute>
		<xsl:attribute name="method">GET</xsl:attribute>
		<xsl:attribute name="action">http://www.amazon.co.jp/gp/aws/cart/add.html</xsl:attribute>
	<input>
		<xsl:attribute name="type">submit</xsl:attribute>
		<xsl:attribute name="name">addtop</xsl:attribute>
		<xsl:attribute name="value">チェックした商品をカートへ</xsl:attribute>	</input>
	<input>
		<xsl:attribute name="type">hidden</xsl:attribute>
		<xsl:attribute name="name">AssociateTag</xsl:attribute>
		<xsl:attribute name="value">nifuba-22</xsl:attribute>
	</input>
	<input>
		<xsl:attribute name="type">hidden</xsl:attribute>
		<xsl:attribute name="name">SubscriptionId</xsl:attribute>
		<xsl:attribute name="value">1RTHSTV200503SRH4RR2</xsl:attribute>
	</input>
	<xsl:apply-templates select="aws:ItemSearchResponse/aws:Items" />
	<input>
		<xsl:attribute name="type">submit</xsl:attribute>
		<xsl:attribute name="name">addbottom</xsl:attribute>
		<xsl:attribute name="value">チェックした商品をカートへ</xsl:attribute>
	</input>
	</form>
	</div>
	</body>
	</html>
</xsl:template>

<xsl:template match="aws:Items">  
	<xsl:apply-templates select="aws:Item" />,
</xsl:template> 

<xsl:template match="aws:Item">
	<xsl:variable name="url" select="aws:DetailPageURL" />
	<xsl:variable name="asin" select="aws:ASIN" />
	<xsl:variable name="name" select="aws:ItemAttributes/aws:Title" />
	
	<xsl:variable name="associate_id">nifuba-22</xsl:variable>
	<xsl:variable name="subscription_id">1RTHSTV200503SRH4RR2</xsl:variable>
	
	<ul class="amazon_item">
		<li>
			<a>
				<xsl:attribute name="target">_blank</xsl:attribute>
				<xsl:attribute name="href">
					<xsl:value-of select="$url" />
				</xsl:attribute>
				<xsl:apply-templates select="aws:MediumImage" />
				<xsl:value-of select="$name"/>
			</a>
		</li>
		
		<li>
			<input>
				<xsl:attribute name="type">checkbox</xsl:attribute>
				<xsl:attribute name="name">ASIN.<xsl:number /></xsl:attribute>
				<xsl:attribute name="value"><xsl:value-of select="$asin" /></xsl:attribute>
				<xsl:attribute name="onClick">javascript:{var num=getElementById("quantity_<xsl:number />");if (this.checked!=true) {num.value=0;}else{num.value=1;}}</xsl:attribute>
			</input><input>
				<xsl:attribute name="type">text</xsl:attribute>
				<xsl:attribute name="name">Quantity.<xsl:number /></xsl:attribute>
				<xsl:attribute name="id">quantity_<xsl:number /></xsl:attribute>
				<xsl:attribute name="value">0</xsl:attribute>
				<xsl:attribute name="size">2</xsl:attribute>
			</input>:購入数
		</li>
		
		<li>
		<xsl:apply-templates select="aws:Offers/aws:Offer/aws:OfferListing" />
		</li>
		<!-- ユーズド価格の表示 -->
		<!-- <xsl:apply-templates select="aws:OfferSummary/aws:LowestUsedPrice" /> -->
	</ul>
</xsl:template>

<xsl:template match="aws:MediumImage">
	<img>
		<xsl:attribute name="src">
			<xsl:value-of select="aws:URL" />
		</xsl:attribute>
	</img>
</xsl:template>

<xsl:template match="aws:OfferListing">
	<xsl:variable name="ourprice" select="aws:Price/aws:FormattedPrice" />
	<xsl:variable name="availavility" select="aws:Availability" />
	
	<xsl:value-of select="$ourprice"/>, 
	<xsl:value-of select="$availavility"/>
</xsl:template>

<!-- ユーズド価格の表示 -->
<!-- <xsl:template match="aws:OfferSummary/aws:LowestUsedPrice">
	<xsl:variable name="used" select="aws:FormattedPrice" />
	<li>Used: <xsl:value-of select="$used"/></li>
</xsl:template> -->

</xsl:stylesheet>

