kuribo_img = new Array(4);
for (i = 0; i < 4; i++) {
  kuribo_img[i] = new Image();
  kuribo_img[i].src = "http://www.kuribo.info/image/set/banner_0" + (i + 1) + ".gif";
}
var kuribo_image_cnt = 0;
function writeImageRanking() {
  document.open();
  document.write('<img src="'+kuribo_img[kuribo_image_cnt].src+'" align="top" style="border-width:0;" />');
  document.close();
  kuribo_image_cnt = (kuribo_image_cnt + 1) % 4;
}
function openEditor() {
  var url_str = document.kuri_search.url.value;
  var user_id = url_str.substr(url_str.indexOf("=")+1);
  if (user_id == "") {
    alert("URL入力が正しくありません");
  } else {
  win = window.open("","_blank","");
    win.document.open();
    win.document.writeln("<html>\n<head><title>Blogger "+user_id+" これまでの投稿を表示</title></he"+"ad>\n<bo"+"dy>\n<br /><br />\n<center>");
    win.document.writeln("<form action='"+"http://www.blogger.com/posts.g?blogID="+user_id+"' style='margin:0;' id='frmFilter' name='frmFilter' method='post'>\n<input type='hidden' name='blogID' value='"+user_id+"'>\n表示数&nbsp;<select name='selNumPosts'>\n<option value='500'> 500 </option>\n<option value='1000'> 1000 </option>\n<option value='3000'> 3000 </option>\n<option value='5000'> 5000 </option>\n<option value='10000'> 10000 </option>\n</select>\n　表示対象&nbsp;<select name='whichPosts'>\n<option selected value='everything'> すべて </option>\n<option value='draft'> 下書き </option>\n<option value='current'> 現状 </option>\n</select>\n　<input value='実行' type='submit' class='filterButton' name='searchButton' size='10'></form>\n</center>");
    win.document.writeln("</body></html>");
    win.document.close();
  }
}
function writeCommentCount(cnt,low) {
  var str = ((cnt == 0)? "No":"" + cnt) + " Comment" + ((cnt > 1)? "s":"");
  if (low) str = str.toLowerCase();
  document.write(str);
}
function togglecomments (postid) {
var whichpost = document.getElementById(postid);
  if (whichpost.className=="commentshown") {
    whichpost.className="commenthidden";
  } else {
    whichpost.className="commentshown"; 
  }
}
function replaceAll(text, a, b) {
  var text2 = text;
  while (text2.indexOf(a) > -1) {
    text2 = text2.replace(a, b);
  }
  return text2;
}
function printCode() {
  var str = document.code.txt1.value;
  var text = str.split("&");
  if (text.length > 1) {
    rn = true;
    str = text[0];
    for (var i = 1; i < text.length; i++) {
      str += "&amp;" + text[i];
    }
  }
  
  str = replaceAll(str, "<", "&lt;");
  str = replaceAll(str, ">", "&gt;");
  str = replaceAll(str, "\"", "&quot;");
  str = replaceAll(str, " ", "&nbsp;");
  
  var rn = false;
  text = str.split("\r\n");
  if (text.length > 1) {
    rn = true;
    str = text[0];
    for (var i = 1; i < text.length; i++) {
      str += "<br />\r\n" + text[i];
    }
  }
  if (!rn) {
    text = str.split("\r");
    if (text.length > 1) {
      str = text[0];
      for (var i = 1; i < text.length; i++) {
        str += "<br />\r" + text[i];
      }
    }
    text = str.split("\n");
    if (text.length > 1) {
      str = text[0];
      for (var i = 1; i < text.length; i++) {
        str += "<br />\n" + text[i];
      }
    }
  }
  document.code.txt2.value = str;
}
function printCode2() {
  var str = document.code.txt1.value;
  str = replaceAll(str, "<", "&lt;");
  str = replaceAll(str, ">", "&gt;");
  document.code.txt2.value = "<pre class=\"prettyprint\">\n"+str+"\n</pre>";
}
function addAmazonLinks() {
  var d = document.getElementsByTagName("div");
  for (var i = 0; i < d.length; i++) {
    if (d[i].className == "amazon-keyword") {
      d[i].innerHTML = '<iframe src="http://tools.kuribo.info/livelink/?key=' + d[i].title + '&n=3&w=468&h=90" marginwidth="0" marginheight="0" width="468" height="90" border="0" frameborder="0" style="border:none;margin-top:15px;" scrolling="no"></iframe>';
    }
  }
}
function addEngine(name, ext, cat, type) {
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) { 
    window.sidebar.addSearchEngine("http://tools.kuribo.info/searchplugin/"+name+".src", "http://tools.kuribo.info/searchplugin/"+name+"."+ext, name, cat);
  } else {
    alert("Sorry, you need a Mozilla-based browser to install a search plugin.");
  }
}
