/*
* @title short url for amazon
* @description AmazonのURLを短くします
* @license MIT License
*/
(function(_d,_a,_b,_c,asinElm,isbnID,winAsin,df,box){
function c(t){return _d.createElement(t)}
function e(id){return _d.getElementById(id)}
function addCSS(cssText,r,s){
s=_d.createElement('style');
s.type='text/css';
r=_d.getElementsByTagName('head')[0]||_d.documentElement;
s.textContent=cssText;
return r.appendChild(s).s
}
function closeBtn(p){
p=this.parentNode;
p.parentNode.removeChild(p);
}
function makeBtn(elm,formText,f,g,h){
f=c('form');
f.id=_c;
elm.appendChild(f);
g=c('textarea');
g.value=formText;
g.id=_a;
f.appendChild(g);
h=c('button');
f.appendChild(h);
h.appendChild(_d.createTextNode('\u00D7'));
h.setAttribute('type','button');
h.addEventListener('click',closeBtn,false);
h.title='close';
}
asinElm = _d.getElementById('ASIN');
winAsin = window.sitbAsin;
if(!asinElm && !winAsin)return;
isbnID = (asinElm)?asinElm.value : winAsin;
textElm = document.getElementById('btAsinTitle').textContent + ' ' + 'http://amazon.jp/dp/' + isbnID;
df=_d.createDocumentFragment();
if(e(_b)){
if(e(_c))e(_c).parentNode.removeChild(e(_c));
makeBtn(df,textElm);
e(_b).appendChild(df);
}else{
addCSS('#'+_a+'{top:30px;right:25px;width:400px;height:60px;z-index:9998;position:fixed;padding:8px;border:5px solid #888;padding:5px;opacity:0.7;}#'+_c+' button{top:20px;right:16px;z-index:9999;position:fixed;background-color:#FF514C;border:3px solid #fff;color:#fff;font-size:15px;height:23px;width:23px;padding:0;opacity:1;cursor:pointer;border-radius:15px;box-shadow:-1px 2px 6px #777;}');
box=c('div');
box.id=_b;
df.appendChild(box);
makeBtn(box,textElm);
_d.body.appendChild(df);
}
e(_a).focus();
})(document,'rko_amzn_textarea','rko_amzn','rko_amzn_form');