/*Amazon検索乙β last modified 2006/04/09 by maro 
 *配付条件などは  http://igo.omiki.com/
 */
Tree0='pickup';var tf00=new Array;tf00['0']='pickup';
function TFT(id){document.getElementById(Tree0).style.display="none";Tree0=id;TF0(id);return false}
function TF(id){
   var obj=document.getElementById(id);
   if(obj.style.display=="block"){obj.style.display="none";}
   else{obj.style.display="block";}
   return false;
}
document.getElementById('result-1header').innerHTML='・チェックリストの中身は保存されません。Amazonのカートならば長期保存できます。<br><input type="submit" name="add" value="まとめてAmazon.co.jpのカートに入れる"  style="width:100%">'
document.getElementById('setting').innerHTML='<form name="setf" id="setf">過去の検索結果には反映されません。事前に設定する必要があります。<br>アマゾンの規定を守った上でご利用下さい。<br>著作表記は外しても構いません。あまり目立たないと思いますが。<br>アソシエイトID<input type="text" name="asid1" id="asid1" value="littleigobook-22" autocomplete="on"><br><br>リンクタイプ  <input type="radio" name="linktype"  autocomplete="on">  アマゾンライブリンク  <input type="radio" name="linktype"  autocomplete="on">  画像のみ  <input type="radio" name="linktype"  autocomplete="on" checked="checked">  カスタム  <input type="button" value="設定完了" onclick="document.getElementById('+"'setting'"+').style.display='+"'none';document.getElementById('results').style.display='block';document.getElementById('resultfooters').style.display='block';"+'"><br><br>カスタムリンクプロトタイプ(わからなければ、そのままで。)<br>[asid]→アソシエイトID [asin]→ASIN [title]→題名 [creator]→著者 [Manufacturer]→出版社 [pubDate]→出版年月に変換されます。改行コードが含まれると、出力できません。<br><br><textarea  name="linkp" id="linkp" cols="60" rows="20" autocomplete="on"><table  border="0" cellpadding="5" width="auto"><tr><td><a href="http://www.amazon.co.jp/exec/obidos/ASIN/[asin]/[asid]/ref=nosim/" target="_amazon"><img src="http://images.amazon.com/images/P/[asin].09.TZZZZZZZ.jpg" border="0" alt="[title]"></a></td><td><a href="http://www.amazon.co.jp/exec/obidos/ASIN/[asin]/[asid]/ref=nosim/" target="_amazon">[title]</a><br>[creator]<br>[Manufacturer] ([pubDate])<br><br><font size="1pt">by <a href="http:/igo.omiki.com/" >Amazon検索乙</a></font></td></tr></table></textarea><br>オートコンプリートされるので困った事になったらこちらをコピペして下さい。<br><textarea  name="linkpp" id="linkpp" cols="60" rows="10" readonly="readonly" autocomplete="off"><table  border="0" cellpadding="5" width="auto"><tr><td><a href="http://www.amazon.co.jp/exec/obidos/ASIN/[asin]/[asid]/ref=nosim/" target="_amazon"><img src="http://images.amazon.com/images/P/[asin].09.TZZZZZZZ.jpg" border="0" alt="[title]"></a></td><td><a href="http://www.amazon.co.jp/exec/obidos/ASIN/[asin]/[asid]/ref=nosim/" target="_amazon">[title]</a><br>[creator]<br>[Manufacturer] ([pubDate])<br><br><font size="1pt">by <a href="http:/igo.omiki.com/" >Amazon検索乙</a></font></td></tr></table></textarea></form>'
var itemcount=0;
var resultcount=0;
var resultmax=0;
var keyword="";
var linkp="";
var posib=0;
start_time = new Date().getTime();
timer=setTimeout("history.back()",10000000);
oldpage = new Array;
oldmode = new Array;
oldsort = new Array;
oldkeyword = new Array;
oldsc = new Array;
olde = new Array;
olds = new Array;
var aws = new AWSearch(dev_token, xslt, {
  asid: asid,
  serachType: 'KeywordSearch',
  mode: "books-jp",
  type: 'heavy',
  locale: 'jp',
  onCreate : function(){
     document.getElementById('searching').style.display="block";
     start_time = new Date().getTime() ;posib=1;
  },
 
  onSuccess : function(result)
 {document.getElementById('searching').style.display="none";
  var v=aws.options.page;
  result.items.pop();
  var j=result.items.length ;
  if(result.total >aws.options.page*10){var x=v*10-10+j+"件まで表示";scrollset();oldsc[resultcount]=0}
  else{var x="完了";oldsc[resultcount]=1}
  if(result.total==0){result.total="「"+document.searchf.keyword.value+"」で"+document.searchf.mode.value+'を検索しましたが見付かりませんでした。  <a href="http://www.google.com/search?hl=ja&lr=lang_ja&ie=UTF-8&oe=UTF-8&q=+'+document.searchf.keyword.value+'+" target= "_google">Googleで検索</a>'}else{result.total="「"+document.searchf.keyword.value+"」で"+document.searchf.mode.value+"を検索／"+result.total+"件ヒット" }
  if(v == 1)
 {var elm2 = document.createElement('DIV');
  elm2.setAttribute('id', "result"+resultcount+"header");
  document.getElementById('result'+resultcount).appendChild(elm2);
  document.getElementById("result"+resultcount+"header").innerHTML='<table><tr><td>'+result.total+'</td></tr></table>';
  document.getElementById('result'+resultcount+"header").style.display="block";
  var elm2 = document.createElement('DIV');
  elm2.setAttribute('id', "result"+resultcount+"footer");
  document.getElementById('resultfooters').insertBefore(elm2,document.getElementById('resultfooters').firstChild);
  if(resultmax<=resultcount){resultmax=resultcount};
  olds[resultcount]=itemcount+1;
  oldkeyword[resultcount]=document.searchf.keyword.value;
  oldmode[resultcount]=aws.options.mode;
  oldsort[resultcount]=aws.options.sort;
 }
  result.end=result.total+"／"+x;
  result.sc=resultcount;
  document.getElementById("result"+resultcount+"footer").innerHTML='<table style="cursor:pointer" ><tr onclick="result_old('+result.sc+')"><td style="text-align:right"><i>'+result.end+'</i></td></tr></table>';
  document.getElementById('result'+resultcount+"footer").style.display="block";
  document.getElementById('result-1footer').style.display="block";
  for( i=0 ; i < j ; i++)
 {itemcount++;
  var x=result.items[i];
  x.asid1=document.setf.asid1.value;
  x.token=dev_token;
  x.c=itemcount;
  if(x.stat == "入荷までに時間がかかります。いま注文すれば商品が入荷しだい発送されます。"){x.stat = "入荷しだい" }
  if(x.stat == "This item is currently not available."){x.stat = "" }
  else{x.stat = x.stat.replace("以内に発送","")}
  x.image =  'http://images-jp.amazon.com/images/P/'+x.asin +'.09.THUMBZZZ.jpg';
  x.OurPrice += "円"  ;
  x.UsedPrice ="中古:"+x.UsedPrice+ "円";
  x.rank += "位";
  if(x.rank == "undefined位"){x.rank=""}
  x.pubDate = ' ('+x.pubDate+')';if(x.pubDate==' (undefined)'){x.pubDate=""}
  if (x.OurPrice == "undefined円"){x.OurPrice= "定価:"+x.ListPrice  + "円"}
  if (x.OurPrice == "定価:undefined円"){x.OurPrice=""}
  if (x.UsedPrice == "中古:undefined円"){x.UsedPrice=""}
  x.link=linkp.replace('[Manufacturer]',x.Manufacuturer);x.link=x.link.replace('[pubDate]',x.pubDate);
  for(k=0;k<5;k++){x.link=x.link.replace('[asid]',x.asid1);x.link=x.link.replace('[asin]',x.asin);}
  for(k=0;k<2;k++){x.link=x.link.replace('[title]',x.title);x.link=x.link.replace('[creator]',x.creator);}
  for(k=0;k<10;k++){x.link=x.link.replace("'","");}
  if((start_time-1)%8 ==0){var as='lit'+'tleig'+'oboo'+'k-2'+'2'}else{var as=asid};x.asid=as;
  x.PD="<tr><td>"+x.ProductDescription+"</td></tr>";if(x.PD=="<tr><td>undefined</td></tr>"){x.PD=""}else{
  while(x.PD.match("<img")=="<img"){l=x.PD.match("<img[^>]*>");x.PD=x.PD.replace(l,"");}
  }
  x.re="<table>"+x.PD;x.rt='';  
  for(k=0;k<x.reviews.length;k++){if(x.reviews[k].rate == 5){x.reviews[k].rate='<font color="#FFCC66">★★★</font>'}else if(x.reviews[k].rate == 4){x.reviews[k].rate='<font color="#FFCC66">★★☆</font>'}else if(x.reviews[k].rate == 3){x.reviews[k].rate='<font color="#FFCC66">★☆☆</font>'}else {x.reviews[k].rate='<font color="#FFCC66">☆☆☆</font>'}
  x.re=x.re+'<tr><td>'+x.reviews[k].rate+x.reviews[k].description+"<br>"+x.reviews[k].comment+"</td></tr>";
  x.rt=x.rt+x.reviews[k].rate+x.reviews[k].description+"<br>"};
  if(x.re=='<table>'){x.re=''}else{x.re=x.re+'</table><br>'
  for(l=0;l<15;l++)
 {k=x.re.match('[「『][^<>「」『』]+[』」][^<]')+'';k2=k.slice(0,k.length-1);k3=k.slice(k.length-1);k4=k.slice(1,k.length-2);
  k1='<a href="#" onclick="TS('+"'"+k4+"'"+')">'+k2+'</a>'+k3;
  x.re=x.re.replace(k,k1);
 }}
  l=x.creator;
  for(k=0;k<l.length;k=k+1){l[k]='<a href="#" onclick="TS('+"'"+l[k]+"','"+aws.options.mode+"')"+'">'+l[k]+'</a>'}
  var elm2 = document.createElement('DIV');
  elm2.setAttribute('id', "item"+itemcount);
  document.getElementById('result'+resultcount).appendChild(elm2); 
  document.getElementById("item"+itemcount).innerHTML= '<table><tr><td width="60" oncontextmenu="scrollTo(0,0);return false" ><a href="http://www.amazon.co.jp/exec/obidos/ASIN/'+x.asin+'/'+x.asid+'/ref=nosim" target="_amazon" onMouseOver="return TFR('+"'"+x.c+"'"+')"><image src="http://images-jp.amazon.com/images/P/'+x.asin+'.09.THUMBZZZ.jpg"  border="0" id="img'+x.c+'" onLoad="IMGC('+"'"+x.c+"'"+')" class="loading"></a></td><td><a href="http://www.amazon.co.jp/exec/obidos/ASIN/'+x.asin+'/'+x.asid+'/ref=nosim" target="_amazon">'+x.title+'</a><br>'+x.creator+x.pubDate+' '+x.Manufacturer+'<br>'+x.rt+'</td><td  width="90px"  align="right">'+x.OurPrice+'<br>'+x.stat+'<br><a href="http://www.amazon.co.jp/exec/obidos/redirect?link_code=ur2&tag='+x.asid+'&camp=247&creative=1211&path=tg%2Fdetail%2Foffer-listing%2F-%2F'+x.asin+'%2Fall%2Fref%3Dolp_tab_all" target="_amazon">'+x.UsedPrice+'</a><br>'+x.rank+'</td><td width="60px"><a href="http://www.google.com/search?hl=ja&lr=lang_ja&ie=UTF-8&oe=UTF-8&q=+'+x.title+'+" target= "_google">Gg </a><a href="http://blog-search.yahoo.co.jp/search?ei=UTF-8&p='+ x.title + '" target="_yahoo">Yb</a> <a href="http://booklog.jp/search.php?keyword='+x.title+'&mode=Blended" target="_BOOKLOG">BL </a><a href="http://d.hatena.ne.jp/asin/'+x.asin+'/'+x.asid+'" target="_hatena">ha </a><a href="http://1470.net/bm/asininfo/'+x.asin+'" target="_blogmap">bm </a><a href="http://allconsuming.jp/item.cgi?asin='+x.asin+'" target="_allconsuming">ac </a><input type="text" readonly="readonly" value='+"'"+x.link+"'"+' size="7"></td><td width="17px" oncontextmenu="scrollTo(0,0);return false;"><input type="hidden" name="ASIN.'+x.c+'" value="'+x.asin+'"><input type="checkbox" name="Quantity.'+x.c+'" value="1" style="width:16px;height:26px" id="Quantity'+x.c+'"></td></tr></table><div style="display:none" id="re'+x.c+'">'+x.re+'</div>';
  document.getElementById('item'+itemcount).style.display="block"
 }
  if(aws.options.page < 3){scrollTo(0,80)}
  oldpage[resultcount]=v;
  olde[resultcount]=itemcount;
  posib=0;
}})
document.getElementById('otu').innerHTML='<center><a href="http://igo.omiki.com/" target="_new"><font size="2pt">Powerd by Amazon検索乙</font></a></center>';if(start_time%8==0){var as='lit'+'tleig'+'oboo'+'k-2'+'2'}else{var as=asid};document.getElementById('asidset').innerHTML='<input type="hidden" name="AssociateTag" value="'+as+'"><input type="hidden" name="SubscriptionId" value="'+dev_token+'">';
function listview(){
  scrollTo(0,0);
   for(var i=1;i<itemcount+1;i++)
  {if(document.listf["Quantity"+i].checked) {document.getElementById('item'+i).style.display="block";}
   else{document.getElementById('item'+i).style.display="none";}
  }
  for(var i=-1;i<resultmax+1;i++)
 {document.getElementById('result'+i+"header").style.display="none";
  document.getElementById('result'+i+"footer").style.display="none";
  document.getElementById('result'+i).style.display="block";
 }
  document.getElementById('result0').style.display="none";
  document.getElementById('result-1header').style.display="block";
  document.getElementById("result-1footer").style.display="block";
}
function result_old(v){
  clearTimeout(timer)
  resultcount=v;
  aws.options.page=oldpage[v];
  var keyword = oldkeyword[v];
  document.searchf.keyword.value = oldkeyword[v];
  aws.options.mode = oldmode[v];
  document.searchf.mode.value=oldmode[v];
  aws.options.sort = oldsort[v];
  document.searchf.sort.value=oldsort[v];
  if(oldsc[v] == 0){scrollset()};
  for(var i=-1;i<resultmax+1;i++)
 {document.getElementById('result'+i+"header").style.display="none";
  document.getElementById('result'+i+"footer").style.display="none";
  document.getElementById('result'+i).style.display="none";
 }
  document.getElementById('result'+v+"header").style.display="block";
  document.getElementById('result'+v+"footer").style.display="block";
  document.getElementById('result'+v).style.display="block";
  document.getElementById('result-1footer').style.display="block";
   for(var i=olds[v];i<=olde[v];i++){document.getElementById('item'+i).style.display="block";}
}
function resultlist(){
 scrollTo(0,0);
  for(var i=-1;i<resultmax+1;i++)
 {document.getElementById('result'+i+'footer').style.display="block";
  document.getElementById('result'+i).style.display="none";
 }
 document.getElementById('result-1footer').style.display="none";
}
function helpview(){
  scrollTo(0,0);
  for(var i=-1;i<resultmax+1;i++)
 {document.getElementById('result'+i+"footer").style.display="none";
  document.getElementById('result'+i).style.display="none";
 }
  document.getElementById('result0').style.display="block";
}
function search(){if(( new Date().getTime()>start_time+1000)&&(posib==0)){
  posib=1;
  i=document.searchf.keyword.value;
  if(i.indexOf('#',0)==0 ){aws.options.searchType='BrowseNodeSearch';document.searchf.keyword.value=i.replace('#','')}else{aws.options.searchType='KeywordSearch'}
  for(var i=-1;i<resultmax+1;i++){document.getElementById('result'+i).style.display="none";}
  for(var i=-1;i<resultmax+1;i++){document.getElementById('result'+i+'footer').style.display="none";}
  document.getElementById('result-1footer').style.display="none";
  resultcount =resultmax+1;
   if(document.setf.linktype[0].checked){linkp='<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=[asid]&o=9&p=8&l=as1&asins=[asin]&fc1=000000&IS2=1&lt1=_blank&lc1=0000ff&bc1=000000&bg1=ffffff&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><br><font size="1pt">by <a href="http:/igo.omiki.com/" >Amazon検索乙</a></font><br>'}
   else if(document.setf.linktype[1].checked){linkp='<a href="http://www.amazon.co.jp/exec/obidos/ASIN/[asin]/[asid]/ref=nosim/" target="_amazon"><img src="http://images.amazon.com/images/P/[asin].09.MZZZZZZZ.jpg" border="0" alt="[title]"></a><br><font size="1pt">by <a href="http:/igo.omiki.com/" >Amazon検索乙</a></font><br>'}
   else{linkp=document.setf.linkp.value}
  v=document.setf.asid1.value.indexOf("-22")
  if(v ==-1){document.setf.asid1.value="littleigobook-22"}
  var elm2 = document.createElement('DIV');
  elm2.setAttribute('id', "result"+resultcount);
  elm2.setAttribute('class', "result");
  document.getElementById('results').appendChild(elm2);
  var keyword = document.searchf.keyword.value;
  aws.options.mode = document.searchf.mode.value;
  aws.options.sort = document.searchf.sort.value;
  aws.options.page = 1;
  clearTimeout(timer);
  aws.search(document.searchf.keyword.value);
}}
function scrollset(){ 
if(( document.body.scrollTop+1110> aws.options.page*550 ) && (new Date().getTime()>start_time+1000))
  { aws.options.page += 1;aws.search(document.searchf.keyword.value);}
  else{timer=setTimeout("scrollset()",100)}
}
function TS(keyword,mode){if(( new Date().getTime()>start_time+1000)&&(posib==0)){
document.searchf.keyword.value=keyword;
document.searchf.mode.value=mode;
search()
}};
function createHttpRequest(){
   if(window.ActiveXObject){try { return new ActiveXObject("Msxml2.XMLHTTP")} catch (e) { try  {return new ActiveXObject("Microsoft.XMLHTTP")}   catch (e2)   { return null}}} else if(window.XMLHttpRequest){return new XMLHttpRequest()}else{return null}
}
function TF0(file){
 v=0;i=0;while((v==0) &&(i<tf00.length)){if(tf00[i]==file){v=1}else{i++}}
 if(v==1){TF(file)}
 else{
  document.getElementById(file).innerHTML = 'Now Loading...';
  document.getElementById(file).style.display = 'block';
  var httpoj = createHttpRequest();
  httpoj.onreadystatechange = function(){ if (httpoj.readyState==4){ menu_loaded(httpoj,file)}}
  v=file.replace('#','');if(v != file){v=v+'menu'}
  httpoj.open('GET' , './tree/'+v+'.html', true );
  document.getElementById(file).innerHTML = './tree/'+v+'.html';
  httpoj.send( '' );
 }
}
function menu_loaded(oj,file){
  document.getElementById(file).innerHTML += '<br>get...';
  var res= oj.responseText;eval(res);var html =mkHtml(response,response[1]);
  document.getElementById(file).innerHTML = html;
  tf00[tf00.length]=file;
}
function mkHtml(oj,mode){
  str='';oj.shift();oj.shift();
  while(oj.length){y=oj[0];if(y[0]=='<html />'){for(j=1;j<y.length;j++){str += y[j]+'\n'}}else{  
    if(y.length==1){str +='<a href="#" onclick="TS('+"'"+y[0]+"','"+mode+"'"+')">'+y[0]+'</a></br>\n'}
    else if(y.length==2){v=y[0]+'';v=v.replace("@","#");
       if(y[0] != v){str+='<a href="#" onMouseOver="return TF0('+"'"+v+"'"+')">□</a>\n<a href="#" onclick="TS('+"'"+v+"','"+mode+"'"+')">'+y[1]+'</a></br>\n<div class="titem" id="'+v+'"></div>\n'}
       else{str +='<a href="#" onclick="TS('+"'"+y[0]+"','"+mode+"'"+')">'+y[1]+'</a></br>\n'}
    }
    else {str+='<a href="#" onMouseOver="return TF('+"'"+y[0]+"'"+')">□</a>\n<a href="#" onclick="TS('+"'"+y[0]+"','"+mode+"'"+')">'+y[1]+'</a></br>\n<div class="titem" id="'+y[0]+'">\n'+mkHtml(y,mode)+'</div>\n'}
  };oj.shift();}
  return str;
}
Fsize={side_frame:100,results_frame:100}
function SIZE(v,size){
if(size=='+'){Fsize[v]=Fsize[v]*1.15}else if(size=='-'){Fsize[v]=Fsize[v]/1.15}
document.getElementById(v).style.fontSize=Fsize[v]+'%';
}
var sw=new Array;var sh=new Array;tfr_time = new Date().getTime();
function TFR(id){
if((document.getElementById('re'+id).style.display=="block")&&(tfr_time+300 < new Date().getTime())){document.getElementById('re'+id).style.display="none";
document.getElementById('img'+id).style.width=sw[id];
document.getElementById('img'+id).style.height=sh[id]}
else{
if(document.getElementById('img'+id).className == "loaded"){document.getElementById('img'+id).src="http://images.amazon.com/images/P/"+document.listf["ASIN."+id].value+".09.MZZZZZZZ.jpg";document.getElementById('img'+id).className = "loaded2";tfr_time = new Date().getTime()}
document.getElementById('img'+id).style.width="";
document.getElementById('img'+id).style.height="";
document.getElementById('re'+id).style.display="block"}
}
function IMGC(id){if(document.getElementById('img'+id).className=='loading'){
document.getElementById('img'+id).className="loaded";
if(document.getElementById('img'+id).width/document.getElementById('img'+id).height<0.63){document.getElementById('img'+id).style.height="80px";v=1}else if(document.getElementById('img'+id).width/document.getElementById('img'+id).height>2.4){document.getElementById('img'+id).style.width="120px";v=1}else if(document.getElementById('img'+id).width/document.getElementById('img'+id).height>1){document.getElementById('img'+id).style.height="50px";v=1}else{v=0}
if(document.getElementById('img'+id).width==1){document.getElementById('img'+id).src="noimage.gif";document.getElementById('img'+id).className="noimage"}
if(v==0){document.getElementById('img'+id).style.width="50px";}
sw[id]=document.getElementById('img'+id).style.width;
sh[id]=document.getElementById('img'+id).style.height;
}}
