// This file is licensed under the MIT license
// https://github.com/sakuratan/AZlink-TinyWidget
typeof AZlink=="undefined"&&(AZlink={});
if(typeof AZlink.TinyWidget=="undefined")AZlink.TinyWidget={},function(j){function m(a,b){var d;if(XMLHttpRequest)d=new XMLHttpRequest;else try{d=new ActiveXObject("MSXML2.XMLHTTP.6.0")}catch(f){try{d=new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(c){d=new ActiveXObject("MSXML2.XMLHTTP")}}d.onreadystatechange=function(){if(d.readyState==4&&b){var a=false;if(d.status==200)try{a=eval("("+d.responseText+")")}catch(c){}b(a,d.status)}};d.open("GET",a);d.send()}function n(a){this.url=a;this.flags=this.country=
null}function i(a,b){a.appendChild(document.createTextNode(b))}function h(a){for(typeof a!="string"&&(a=String(a));;){var b=a.replace(/^([+-]?\d+)(\d\d\d)/,"$1,$2");if(b==a)break;a=b}return a}function p(a,b,d,f){var c=b[d],e=document.createElement("a");e.href=c.link;e.className="azlink-widget-associate-link";if(f.onClickHook)e.onclick=function(){return f.onClickHook(c)};b=document.createElement("img");b.src=c.image;b.alt="";b.title=c.title;b.className="azlink-widget-image";e.appendChild(b);e.appendChild(document.createElement("br"));
b=document.createElement("span");b.className="azlink-widget-title";if(f.order){var g=document.createElement("b");i(g,d+1+"\u4f4d");b.appendChild(g);i(b," ")}i(b,c.title);e.appendChild(b);if(!f.type||f.type!="detail")a.appendChild(e);else{d=[];d.push(e);if(c.info)for(e=0;e<c.info.length;++e)b=document.createElement("span"),b.className="azlink-widget-iteminfo",i(b,c.info[e]),d.push(b);if(c.platform)b=document.createElement("span"),b.className="azlink-widget-iteminfo",i(b,c.platform),d.push(b);if(c.date)b=
document.createElement("span"),e=new Date,g=c.date.split("-"),g=new Date(parseInt(g[0]),parseInt(g[1])-1,parseInt(g[2])),b.className=g>e?"azlink-widget-date azlink-widget-new-item":"azlink-widget-date",e=c.date.replace(/-/g,"/"),i(b,e),d.push(b);e=null;c.lower_new_price&&c.upper_new_price?e=h(c.lower_new_price)+"\u5186 - "+h(c.upper_new_price)+"\u5186":c.new_price&&c.used_price?e=c.new_price<c.used_price?h(c.new_price)+"\u5186\u304b\u3089":c.new_price!=c.used_price?h(c.used_price)+"\u5186\u304b\u3089\uff08\u65b0\u54c1"+
h(c.new_price)+"\u5186\uff09":h(c.new_price)+"\u5186":c.new_price?e=h(c.new_price)+"\u5186":c.used_price?e=h(c.used_price)+"\u5186\u304b\u3089":c.list_price&&(e=h(c.list_price)+"\u5186");if(e)b=document.createElement("span"),b.className="azlink-widget-price",i(b,e),d.push(b);for(e=0;e<d.length;++e)e>0&&i(a," "),a.appendChild(d[e])}}function r(a,b){var d=document.createElement("div");d.className="azlink-widget azlink-sidebar-widget";for(var f=0;f<a.length;++f){b._brReqd&&f>0&&d.appendChild(document.createElement("br"));
var c=document.createElement("div");c.className="azlink-widget-item azlink-sidebar-widget-item";f==0&&(c.className+=" azlink-widget-first-item azlink-sidebar-widget-first-item");f==a.length-1&&(c.className+=" azlink-widget-last-item azlink-sidebar-widget-last-item");p(c,a,f,b);d.appendChild(c)}return d}function s(a,b){var d=document.createElement("table"),f=document.createElement("tbody"),c=document.createElement("tr");d.className="azlink-widget azlink-banner-widget";d.appendChild(f);f.appendChild(c);
for(f=0;f<a.length;++f){var e=document.createElement("td");e.className="azlink-widget-item azlink-banner-widget-item";f==0&&(e.className+=" azlink-widget-first-item azlink-banner-widget-first-item");f==a.length-1&&(e.className+=" azlink-widget-last-item azlink-banner-widget-last-item");p(e,a,f,b);c.appendChild(e)}return d}function o(a){if(a<1)return 0;for(;;){var b=Math.random(),b=Math.floor(b*a);if(b!=a)return b}}function t(){var a=["bestsellers","new-releases","movers-and-shakers","most-gifted",
"most-wished-for"],b="dvd,toys,videogames,software,electronics,watch,books,musical-instruments,music".split(",");return a[o(a.length)]+"/"+b[o(b.length)]}function q(a){if(typeof k!="undefined"){var b="azlink-widget-embed-stub-"+u++;document.write('<span id="'+b+'" style="display:none"></span>');a.onload=function(a,f){var c=document.getElementById(b),e=f.generator(a,f),g=c.parentNode;if(e)if(typeof e=="string"){var l=document.createElement("div");for(l.innerHTML=e;l.childNodes.length>0;)e=l.firstChild,
l.removeChild(e),g.insertBefore(e,c)}else g.insertBefore(e,c);g.removeChild(c)};j.api(a)}}var k=function(){var a,b;if(document.getElementsByTagName)b=document.getElementsByTagName("script");else if(document.scripts)b=document.scripts;b&&(a=b[b.length-1].src.replace(/[#\?].*$/,"").replace(/[^\/]*$/,""));return a}();n.prototype.toString=function(){var a="";this.country&&(a+="."+this.country);this.flags&&(a+=".",a+=typeof this.flags=="string"?this.flags:"_"+this.flags.join("_")+"_");return!a?this.url:
this.url.replace(/(?:\.[^\/\.]+)*(\.[^\/\.]+)$/,a+"$1")};j.api=function(a){if(typeof k!="undefined"){var b;b=a.node?typeof a.node=="string"?a.node:a.node[o(a.node.length)]:t();if(typeof a.imageFlags=="undefined")a.imageFlags=["AA160"];var d=document.getElementsByTagName("script");if((!d||!d.length)&&!document.body&&!document.documentElement)throw"Missing script or body element";var f=function(b){b=b&&b.items?b.items:[];typeof a.numItems!="undefined"&&b.splice(a.numItems);for(var c=0;c<b.length;++c){var d=
b[c],f=["http://www.amazon.co.jp/exec/obidos/ASIN",d.asin];a.associateId&&f.push(a.associateId);f.push("ref=nosim/");d.link=f.join("/");d.image=typeof d.image=="undefined"?new n("http://ecx.images-amazon.com/images/G/09/nav2/dp/no-image-no-ciu.gif"):new n(d.image);if(a.imageFlags)d.image.flags=a.imageFlags}a.onload(b,a)},d=k+"json/"+b+".js",c=k+"api.php?node="+encodeURIComponent(b);m(d,function(a,b){if(b==404)m(c,f);else{if(a&&a.expire){var d=new Date(a.expire),h=new Date,i=typeof a.probability==
"undefined"?1:parseFloat(a.probability);if(d.getTime()<h.getTime()&&Math.random()<=i){m(c,f);return}}f(a,b)}})}};var u=0;j.sidebar=function(a){a=a?a:{};a.generator=r;q(a)};j.banner=function(a){a=a?a:{};a.generator=s;q(a)}}(AZlink.TinyWidget);

