/*
 JavaScript lib.js by martin $ 2007/05/08 02:30:54
*/
var d = document;
var ie = (d.selection && !window.opera) ? 1 : 0;
var lt7 = navigator.appVersion.match(/MSIE [56]/) ? 1 : 0;
var moz = (d.getSelection && !window.opera) ? 1 : 0;
var kht = navigator.userAgent.match(/webkit|safari|khtml/i) ? 1 : 0;
var w3c = (d.getElementById && !d.all) ? 1 : 0;
var smilies = {};
var caretSelection = "", toolTip, ed;
var ImagePath = "Images", i = 0, _scripts = d.getElementsByTagName("script"), l = _scripts.length || 1;
while(i < l){
 if(typeof _scripts[i] != "undefined" && _scripts[i].id != ""){
  ImagePath = 'theme/'+_scripts[i].id+'/Images'; break;
 }i++;
};
var loadingAni = new Image().src = ImagePath+'/loading.gif';
var expandImg = new Image().src = ImagePath+'/expand.png';
var unexpandImg = new Image().src = ImagePath+'/unexpand.png';
var screenBack = new Image(1,1).src = ImagePath+'/screen.png';
var closeButton = new Image().src = ImagePath+'/button-close.png';

function googleIt(query){
 window.open(encodeURI("http://www.google.com/search?hl=ja&ie=UTF-8&oe=UTF-8&q="+query));
}
function wikipediaIt(query){
 window.open("http://ja.wikipedia.org/wiki/%E7%89%B9%E5%88%A5:Search?search="+encodeURI(query));
}

if(w3c && Event.prototype){
 try {
  for (var property in Event.prototype){
   if(property.match(/MOUSE|CLICK/)){
    window.addEventListener(property.toLowerCase(), function(e){window.event=e}, true);
   }
  }
 } catch (e){};
};

function getClientWidth(){
 return d.documentElement.clientWidth || self.innerWidth || d.body.clientWidth || 0;
}

function getClientHeight(){
 return self.innerHeight || d.documentElement.clientHeight || d.body.clientHeight || 0;
}

function getDocHeight(){ 
 var h; h = d.documentElement.scrollHeight || d.body.scrollHeight || 0;
 return (arguments.length==1) ? h + 'px' : h;
}

function getEventPageX(){
 var ev = window.event;
 return ev.pageX || d.documentElement.scrollLeft + ev.clientX || d.body.scrollLeft + ev.clientX || 0;
}

function getEventPageY(){
 var ev = window.event;
 return ev.pageY || d.documentElement.scrollTop + ev.clientY || d.body.scrollTop + ev.clientY || 0;
}

function getElementPosition(){
 var _x = 0, _y = 0, ev = window.event;
 var ob = ev.target || ev.srcElement;
 if(ob && ob.offsetParent){
  while (ob.offsetParent){
   _x += ob.offsetLeft; _y += ob.offsetTop;
   ob = ob.offsetParent;
  }
 }
 return [_x, _y];
}

function getScrollY(){
 return self.pageYOffset || d.documentElement.scrollTop || d.body.scrollTop || 0;
}

function my_confirm(text){
 text += "削除しますか？";
 if(!confirm(text)) return false; else return true;
}

function readMore(self){
 var ob = self.parentNode.childNodes[1]; // Thanks, Saru-san!
 if(ob.style.display!="block"){
  ob.parentNode.firstChild.title = '記事をたたむ';
  ob.parentNode.firstChild.innerHTML = '&laquo;やっぱり隠す';
  ob.parentNode.firstChild.style.backgroundPosition = "0 100%";
  ob.style.display = "block";
  if(/corner\-play/.test(ob.innerHTML)) cornerPlay(ob);
 } else if(ob.style.display=="block") {
  ob.parentNode.firstChild.title = '続きをよむ';
  ob.parentNode.firstChild.innerHTML = '&raquo;続きを読む';
  ob.parentNode.firstChild.style.backgroundPosition = "0 0";
  ob.style.display = "none";
 }
}

function toggleBox(ob){
 var p = ob.parentNode.parentNode;
 var el = getByClass("sidebar-"+p.id, p);
 if(el==null) return;
 if(arguments[1]){
  el[0].style.display = arguments[1]=="x" ? "none" : "block";
 } else el[0].style.display = el[0].style.display=="none" ? "block" : "none";
 ob.style.backgroundPosition = el[0].style.display=="block" ? "0px 0px" : "0px 100%";
 ob.title = el[0].style.display=="block" ? "閉じます" : "展 開！";
 Cookie.set("PPBLOG_SIDEBAR_"+p.id.toUpperCase()+"_STATE", el[0].style.display=="none" ? "x" : "o");
}

var Caret = { // マウスで指定したポイントあるいは文字列に要素を挿入
 get : function(){
  if(typeof ed == "undefined"){
   if(o("Page1")!=null) ed = o("Page1");
   else if(o("c_com")!=null) ed = o("c_com");
   else ed = o("$TEXTAREA")[0];
  }
  if(ie){
   if(!d.selection.createRange()) ed.focus();
   ed.selected = d.selection.createRange().duplicate();
  } else if(d.getSelection){
   ed.selected = ed.value.substring(ed.selectionStart, ed.selectionEnd);
  } else ed.selected = ' ';
  return caretSelection = (ie) ? ed.selected.text : ed.selected;
 },
 set : function(string){
  if(typeof caretSelection == "undefined" || typeof ed == "undefined") Caret.get();
  if(ie){
   if(caretSelection.length > 0){
    ed.selected.text = string;
    ed.selected.select();
   } else {
    ed.focus();
    ed.selected = d.selection.createRange().duplicate();
    ed.selected.text = string;
   }
  } else if(d.getSelection && caretSelection.length>=0 && ed.selectionStart>=0){
    var s = ed.selectionStart;
    var scrollTop = ed.scrollTop;
    ed.value = ed.value.slice(0,s)+ed.value.slice(s).replace(caretSelection, string);
    ed.setSelectionRange(eval(s+string.length), eval(s+string.length));
    ed.scrollTop = scrollTop;
    ed.focus();
  } else ed.value += string;
 }
}

function hackFirefoxToolTip(){
 var imgs = o('$IMG');
 MozToolTip = Element("DIV", {backgroundColor:"ivory", border:"1px solid #333", padding:"1px 3px", font:"500 11px arial", zIndex:10000, top:-100});
 MozToolTipShadow = Element("DIV", {MozOpacity:0.3, MozBorderRadius:"3px", background:"#000", zIndex:(MozToolTip.style.zIndex - 1)})
 var i = 0, l = imgs.length;
 while(i<l){
  if(imgs[i].getAttribute('title') != null || imgs[i].getAttribute('alt') != null){
   addEvent(imgs[i], "mouseover", function(){
    if(typeof MozToolTip == 'undefined') return;
    this._title = this.getAttribute('title')!=null ? this.getAttribute('title') : this.getAttribute('alt');
    this.setAttribute('title', '');
    this._title = this._title.replace(/[\r\n]+/g,'<br/>').replace(/\s/g,'&nbsp;');
    if(this._title=='') return;
    if(typeof setXY == 'undefined') return;
    setXY(MozToolTip, 20 + event.pageX, 30 + event.pageY);
    MozToolTip.innerHTML = this._title;
    setWH(MozToolTipShadow, MozToolTip.offsetWidth -2, MozToolTip.offsetHeight -2);
    setXY(MozToolTipShadow, parseInt(MozToolTip.style.left) + 5, parseInt(MozToolTip.style.top) + 5);
   });
   addEvent(imgs[i], "mouseout", function(){
    if(typeof MozToolTip == 'undefined') return;
    this.setAttribute('title', MozToolTip.innerHTML.replace(/<br\/>/g,'&#13;&#10;').replace(/&nbsp;/g,' '));
    if(typeof setXY == "function"){
     setXY(MozToolTip, -1000, -1000);
     setXY(MozToolTipShadow, -1000, -1000);
     MozToolTip.innerHTML = '';
    }
   });
  }
  i++;
 }
 if(d.body){
  d.body.appendChild(MozToolTipShadow);
  d.body.appendChild(MozToolTip);
 }
}

function cornerPlay(elm){
 var RS = getByClass("corner-play", elm);
 if(RS==null) return;
 var cord = 0.4;
 var content, inlineCSS, bg, pbg, color, textAlign, borderColor, margin, padding, background, width, b, base1, base2, base3;
 var $r, $g, $b, c3d0, c3d1, c3d2, c3d3, c3d4, reg;
 var frame = '<span><span></span><span></span><span></span><span></span></span>';
 var i = 0, l = RS.length, RSi, P, RP, type;
 while(i < l){
  RSi = RS[i];
  RP = RSi.parentNode;
  if(typeof RSi.corner_played == "undefined"){
   RSi.corner_played = false;
   while (RP){
    if(RP.className == "article") break;
    if(RP.className == "readmore-div"){ RP = RP.className; break; }
    RP = RP.parentNode;
   }
  }
  if(RP=="readmore-div" || RSi.corner_played == true) break;
  type = RSi.className.indexOf('outset') > 0 ? 'outset' : 'rounded';
  type = RSi.className.indexOf('square') > 0 ? 'square' : type;
  content = RSi.innerHTML;
  inlineCSS = (' '+RSi.style.cssText.toLowerCase().replace(/;$/,'')+';'), bg = $HEX(RSi);
  width = (reg=inlineCSS.match(/ (width: ?[^;]+);/)) ? RegExp.$1+';' : '';
  margin = (reg=inlineCSS.match(/margin[^;]+?;/g)) ? reg.join('') : '';
  padding = (reg=inlineCSS.match(/padding[^;]+?;/g)) ? reg.join('') : '';
  color = (reg=inlineCSS.match(/ (color: ?[^;]+);/)) ? RegExp.$1+';' : '';
  borderColor = (reg=inlineCSS.match(/border\-([^:]+?|)color:\s?([^;]+?);/g)) ? reg[0].split(/: /)[1].replace(/;/,'') : '';
  textAlign = (reg=inlineCSS.match(/ (text\-align: ?[^;]+);/)) ? RegExp.$1+';' : '';

  width = width=='' ? 'width: ' + getRuntimeStyle(RSi, 'width') + (window.opera?'px;':';') : width;
  if(margin=='') margin = 'margin: 1em auto;';
  if(padding=='') padding = 'padding: .2em 1em;';
  color = color=='' ? 'color: ' + getRuntimeStyle(RSi, 'color') + ';' : color;
  textAlign = textAlign=='' ? 'text-align: ' + getRuntimeStyle(RSi, 'textAlign') + ';' : textAlign;
  if(!ie) borderColor = borderColor=='' ? getRuntimeStyle(RSi, 'borderColor') : borderColor;
  if(borderColor=='' || borderColor=='transparent'){
   pbg = $HEX(RSi.parentNode);
   borderColor = 'rgb('+parseInt((pbg[0]+bg[0])*cord)+','+parseInt((pbg[1]+bg[1])*cord)+','+parseInt((pbg[2]+bg[2])*cord)+')';
  } else {
   borderColor = $HEX(null, borderColor);
   borderColor = 'rgb('+borderColor[0]+','+borderColor[1]+','+borderColor[2]+')';
  }
  background = 'background-color: rgb('+bg[0]+','+bg[1]+','+bg[2]+');';
  RSi.style.cssText = 'border-color: transparent; background-color: transparent; '+width+margin+color+textAlign;
  if(RSi.nodeName.toUpperCase()=="P"){
   P = RSi; RSi = d.createElement('DIV'); RSi.style.cssText = P.style.cssText;
   P.parentNode.insertBefore(RSi, P); P.parentNode.removeChild(P);
  }
  RSi.innerHTML = frame + '<div>' + content + '</div>' + frame;
  b = RSi.getElementsByTagName("span");
  base1 = 'display:block; overflow:hidden; font-size:1px;'; base2 = 'height:1px;';
  
  switch (type) {
   case 'rounded' :
    base3 = background+' border-left:1px solid '+borderColor+'; border-right:1px solid '+borderColor+';';
    b[0].style.cssText = base1;
    b[1].style.cssText = base1 + base2 + 'margin:0 5px; background:'+borderColor+';';
    b[2].style.cssText = base1 + base2 + base3 + 'margin:0 3px; border-width:0 2px;';
    b[3].style.cssText = base1 + base2 + base3 + 'margin:0 2px;';
    b[4].style.cssText = base1 + base3 + 'height:2px; margin:0 1px;';
    b[5].style.cssText = b[0].style.cssText; b[6].style.cssText = b[4].style.cssText;
    b[7].style.cssText = b[3].style.cssText; b[8].style.cssText = b[2].style.cssText;
    b[9].style.cssText = b[1].style.cssText;
    RSi.childNodes[1].style.cssText = background+'; border:0px solid '+borderColor+'; border-width:0 1px; '+padding;
    break;
   case 'outset' :
    borderColor = borderColor.replace(/rgb\(/,'').replace(/\)/,'').split(',');
    $r = ($r=borderColor[0]) > 255 ? 255 : $r;
    $g = ($g=borderColor[1]) > 255 ? 255 : $g;
    $b = ($b=borderColor[2]) > 255 ? 255 : $b;
    c3d0 = 'rgb('+$r+','+$g+','+$b+')';
    c3d1 = 'rgb('+parseInt($r*.9)+','+parseInt($g*.9)+','+parseInt($b*.9)+')';
    c3d2 = 'rgb('+parseInt($r*.8)+','+parseInt($g*.8)+','+parseInt($b*.8)+')';
    c3d3 = 'rgb('+parseInt($r*.7)+','+parseInt($g*.7)+','+parseInt($b*.7)+')';
    c3d4 = 'rgb('+parseInt($r*.6)+','+parseInt($g*.6)+','+parseInt($b*.6)+')';
    b[0].style.cssText = b[5].style.cssText = base1;
    b[1].style.cssText = base1 + base2 + 'margin:0 5px; background:'+c3d0+';';
    b[2].style.cssText = base1 + base2 + background
      + 'border-left:2px solid '+c3d0+'; border-right:2px solid '+c3d1+'; margin:0 3px;';
    b[3].style.cssText = base1 + base2 + background
      + 'border-left:1px solid '+c3d0+'; border-right:1px solid '+c3d2+'; margin:0 2px;';
    b[4].style.cssText = base1 + background
      + 'border-left:1px solid '+c3d1+'; border-right:1px solid '+c3d3+'; height:2px; margin:0 1px;';
    b[6].style.cssText = base1 + background
      + 'border-left:1px solid '+c3d1+'; border-right:1px solid '+c3d4+'; height:2px; margin:0 1px;';
    b[7].style.cssText = base1 + base2 + background
      + 'border-left:1px solid '+c3d1+'; border-right:1px solid '+c3d4+'; margin:0 2px;';
    b[8].style.cssText = base1 + base2 + background
      + 'border-left:2px solid '+c3d3+'; border-right:2px solid '+c3d4+'; margin:0 3px;';
    b[9].style.cssText = base1 + base2 + 'margin:0 5px; background:'+c3d4+';';
    RSi.childNodes[1].style.cssText = background + 'border-left:1px solid '+c3d0+'; border-right:1px solid '+c3d4+';'+padding;
    break;
   case 'square' :
    b[0].style.cssText = b[5].style.cssText = base1;
    b[1].style.cssText = base1 + background
      + 'height:5px; margin:0 6px; border:solid 1px '+borderColor+'; border-bottom-width:0;';
    b[4].style.cssText = b[6].style.cssText = base1 + base2 + background
      + 'margin:0; border-style:solid; border-width:0 7px; border-color:'+borderColor+';';
    b[9].style.cssText = base1 + background
      + 'height:5px; margin:0 6px; border:solid 1px '+borderColor+'; border-top-width:0;';
    RSi.childNodes[1].style.cssText = background + padding
      + 'border-left:1px solid '+borderColor+'; border-right:1px solid '+borderColor+';';
    break;
  }
  i++; RSi.corner_played = true;
 }
}

function customBox(ob){
 var contents = ob.innerHTML;
 ob.innerHTML = "";
 var _bt = d.createElement("DIV");
 _bt.style.cssText = "background:url(Images/cssbox.png) no-repeat 100% 0;margin:0 0 0 17px;height:17px;padding:0;";
 _bt.innerHTML = '<div style="position:relative;left:-17px;width:17px;height:17px;margin:0;background:url(Images/cssbox.png) no-repeat 0 0;line-height:0;font-size:0;"></div>';
 ob.insertBefore(_bt, ob.firstChild);
 var _bb = d.createElement("DIV");
 _bb.style.cssText = "background:url(Images/cssbox.png) no-repeat 100% 100%;height:17px;margin:0 0 0 17px;";
 _bb.innerHTML = '<div style="position:relative;left:-17px;width:17px;height:17px;margin:0;background:url(Images/cssbox.png) no-repeat 0 100%;line-height:0;font-size:0;"></div>';
 var _bl = d.createElement("DIV");
 _bl.style.cssText = "background:url(Images/bl.png) repeat-y 0 0; padding-left: 12px;height:100%;";
 _bl.innerHTML = '<div style="background: url(Images/br.png) repeat-y 100% 0;padding:0;height:100%;"><div style="background:#fff;height:100%;margin:0 12px 0 0px;padding:1em;">'+contents+'</div></div>';
 ob.insertBefore(_bl, ob.firstChild.nextSibling);
 ob.insertBefore(_bb, null);
}

var Ajax = {
 request : function(){
  return window.XMLHttpRequest ? 
  new XMLHttpRequest() : (window.ActiveXObject) ?
  new ActiveXObject(navigator.appVersion.match(/MSIE 5/) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP") : null;
 },
 get : function(url, func){
  var r = Ajax.request();
  try {
   r.open("GET", url, true);
   r.onreadystatechange = function(){
    Ajax.debug("Now Loading.. "+ url + " : " + r.readyState);
    if(r.readyState==4){
     if(func) func(r.responseText);
     Ajax.debug("");
    }
   }
   r.setRequestHeader("If-Modified-Since", "Thu, 01 Jun 1970 00:00:00 GMT");
   r.send(null);
  } catch (e){Ajax.debug(e,1)}
 },
 post : function(url, data, func){
  var r = Ajax.request();
  try {
   r.open("POST", url, true);
   r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   r.onreadystatechange = function(){
    if(r.readyState==4){
     if(func) func(r.responseText);
    }
   }
   r.send(data);
  } catch (e){Ajax.debug(e,1)}
 },
 cloneScript : function(src){
  var id = src.split(/\//).pop().replace(/\./, '_');
  var s = d.createElement("script");
  var r = Ajax.request();
  s.setAttribute('type', 'text/javascript');
  s.setAttribute('id', id);
  s.setAttribute('charset', 'utf-8');
  if(kht) s.setAttribute('src', src);
  if(!d.getElementById(id)){
   o("$head")[0].appendChild(s);
  } else return true; // cached
  r.open("GET", src, false); // Not async.
  r.setRequestHeader("If-Modified-Since", "Thu, 01 Jun 1970 00:00:00 GMT");
  r.send(null);
  if(r.readyState==4){
   if(r.status==200){
    s.text = r.responseText; // text property!
    return true;
   }
  }
  if(d.getElementById(id)){
   d.getElementById(id).parentNode.removeChild(d.getElementById(id));
   Ajax.debug("404 error : " + src);
  }
  return false;
 },
 debug : function(d, a){!a ? (window.status=d) : alert("Ajax debug: "+d);}
}

function comments_in_situ(uid, author, allowed){
 Ajax.cloneScript("ajax.php?type=info");
 var FILTER = {'&#96;':"`", '&#44;':",", '&#124;':"|", '&#36;':"$", '&yen;':'\\', '&quot;':"\""};
 var ob = window.event.target || window.event.srcElement;
 var loaded = Ajax.cloneScript('ajax.php?type=json&aim=owner/smiley.ini.php');
 var articleBottom = getByClass("article-bottom", o("UID"+uid), "DIV")[0] ||
  getByClass("article-united-bottom", o("UID"+uid), "DIV")[0] || null;
 var eX = getEventPageX(), eY = getEventPageY();
 if(o("ajaxToolTip")==null){
  toolTip = Element("DIV#ajaxToolTip",
   {backgroundColor:"ivory", border:"1px solid #333", padding:"2px 3px", width:140, font:"500 13px MS P Gothic, Osaka", textAlign:"center",
    zIndex:10000, left:eX + (getClientWidth()/2<eX?-200:200), top:eY}
  );

  toolTip.innerHTML = 'コメント読み込み中...';
  d.body.appendChild(toolTip);
 } else {
  toolTip = o("ajaxToolTip");
  toolTip.innerHTML = 'コメント読み込み中...';
  setXY(toolTip, eX + 100, eY);
 }
 var externalLink = ' <img src="'+ImagePath+'/external-link.png" width="12" height="12" alt="Link" title="外部リンク" />';
 var callback = function(data){
  var commentDiv = Element("DIV.comment-div", {position:"relative", marginLeft:"13px"});
  data = data.replace(/\[\[(.+?):http:\/\/(.+?)\]\]/gm,
   function (s0, s1, s2){
    return '<a href="http://'+s2+'" onclick="window.open(this.href,\'\');return false;" rel="nofollow">'+s1+'</a>'+externalLink;
  });
  data = data.replace(/[^"\|]http:\/\/([;\/\?:@&=\+\$,\w\-\.!~%#]+)/gm,
   function (s0, s1){
    return '<a href="http://'+s1+'" onclick="window.open(this.href,\'\');return false;" rel="nofollow">http://'+s1+'</a>'+externalLink;
   });
  data = data.replace(/\[q\]`?(.+?)`?\[\/q\]/gm, '<p class="comment-quote">$1</p>');
  for (var i in smilies){
   var r = new RegExp(i.toString().replace(/(\W)/, "\\$1"), "g");
   data = data.replace(r, smilies[i]);
  }
  var cmt = '', nondisc = '', aj = data.split("\n"), ajlen = aj.length;
  if(typeof ADMIN == "undefined") ADMIN = false;
  if(ajlen > 1){
   var ID = aj[0].split('|')[0], NO = isNondiscUsr = 0, tip = '';
   var a, cip, cmail, tip, uconf = Cookie.get("PPBLOG_UCONF");
   var d, Y, mn, day, h, mt, s, u, cbody, cntrl, res;
   for(i=1; i < ajlen-1; i++){
    a = aj[i].split('|'); // a[1] = submitter
    cip = a[4]!=0 ? ' IP: '+a[4] : ' IP: -';
    cmail = (a[6]=='') ? '' : ' <span style="color:rgb(250, 60, 5);font-size:11px;">メールアドレス登録あり</span>';
    if(uconf !=  null){
     tip = unescape(uconf).split(',').pop();
     if(tip==encodeURIComponent(a[1]+a[4])) isNondiscUsr = a[1];
    }
    if(a[7]==1){
     if(!OADMIN){
      if(a[1]==ONAME){
       if(isNondiscUsr && aj[i-1].indexOf("|"+isNondiscUsr+"|")!=-1){
        isNondiscUsr = a[1];
       } else continue;
      } else {
       if(tip==encodeURIComponent(a[1]+a[4])){ // 非公開指定したユーザーっぽい
        isNondiscUsr = a[1];
       } else continue;
      }
      if(isNondiscUsr){ NO++; c_nondisc = ' non-disclosure'; }
     } else { // ADMINなら
      NO++; c_nondisc = ' non-disclosure';
     }
    } else { NO++; c_nondisc = ''; }
    d = new Date(a[0]*1000), Y = d.getFullYear(), mn = d.getMonth()+1, day = d.getDate();
    h = d.getHours(), mt = d.getMinutes(), s = d.getSeconds();
    h = (h < 10) ? "0"+h : h; mt = (mt < 10) ? "0"+mt : mt; s = (s < 10) ? "0"+s : s;
    u = a[5]!='' ? ' <a href="'+a[5]+'" onclick="window.open(this.href,\'\');return false;"><img src="'+ImagePath+'/home.png" alt="Website" title="Website" class="home-icon" /></a>' : '';
    cbody = a[3].replace(/`/gm, " <br /> ");
    cntrl = (OADMIN || UNAME==a[1]) ?
     '<span class="comment-cntrl"><a  href="admin.php?mode=edit_comment&amp;UID='+uid+'&amp;CID='+a[0]+'"><img src="'+ImagePath+'/edit-comment.png" alt="Edit" title="このコメントの編集" /></a> <a  href="admin.php?mode=delete_comment&amp;UID='+uid+'&amp;CID='+a[0]+'" onclick="return my_confirm(\'このコメントを\')"><img src="'+ImagePath+'/del-comment.png" alt="Delete" title="このコメントの削除" /></a> ' : '';
    res = (OADMIN || UNAME==a[1]) ?
     '<a href="admin.php?mode=res_comment&amp;UID='+uid+'&amp;CID='+a[0]+'"><img src="'+ImagePath+'/reply.png" alt="Reply" title="このコメントに返事を書く" /></a></span>' : '';
    cmt += (author==a[1] ? ' <div class="comment-entry-owner">\n' : ' <div class="comment-entry'+c_nondisc+'">\n');

    if(author==a[1]){ // owner
     cmt += ('  <p><a class="owner" id="CID'+a[0]+'" title="Permalink" href="index.php?UID='+ID+'#CID'+a[0]+'"> <img src="'+ImagePath+'/owner-comment.png" class="comment-owner" title="Permalink" alt="Owner Comment" /></a> '+a[1]+u+' &mdash; '+Y+'/'+mn+'/'+day+'@'+h+':'+mt+':'+s+'</p>\n');
    } else {
     cmt += ('  <p class="comment-index"><a class="No" id="CID'+a[0]+'" title="Permalink" href="index.php?UID='+ID+'#CID'+a[0]+'">'+NO+'.</a> '+a[1]+u+' &mdash; '+Y+'/'+mn+'/'+day+'@'+h+':'+mt+':'+s+' '+(ADMIN?cip+' '+cmail:'')+'</p>\n');
    }
    cmt += ('  <div class="comment-body" style="color:#'+a[2]+';">'+cbody+cntrl+res+'</div>\n');
    cmt += '</div>\n';
    if(i < ajlen-1 ) cmt += '<hr class="comment-separator" />\n';
   } //for-loop
   if(allowed){
    cmt += '<div class="commentFormHere"><button type="button" onclick="loadCommentForm('+uid+');return false;" title="コメントする">Add your comment</button></div>\n';
   } else {
    cmt += '<p class="comment-closed">この記事に対するコメントは締め切られています</p>\n';
   }
   cmt += '</div><!--#comment-div-->\n';
  }
  for (var i in FILTER){ cmt = cmt.replace(new RegExp(i, "g"), FILTER[i]); }
  commentDiv.innerHTML = cmt;
  articleBottom.appendChild(commentDiv);
  if(ob){
   ob.firstChild.data = ob.firstChild.data.replace(/\[\+\]/,"[-]");
   ob.title = "表示したコメントを隠します";
  }
  toolTip.innerHTML = ' コメント読み込み完了！ ';
  setTimeout('toolTip.style.top = "-1000px"', 500);
 } //#callback
 if(articleBottom.innerHTML.match(/comment-div/)){ // already loaded and displayed
  var comment = getByClass("comment-div", articleBottom, "DIV")[0];
  toolTip.style.display = "none";
  if(comment.style.display!="none"){
   comment.style.display = "none";
   if(ob) ob.firstChild.data = ob.firstChild.data.replace(/\[\-\]/,"[+]");
   return;
  } else {
   comment.style.display = "block";
   if(ob) ob.firstChild.data = ob.firstChild.data.replace(/\[\+\]/,"[-]");
   return;
  }
 }
 if(!loaded){
  return;
 } else {
  Ajax.get('ajax.php?type=text&aim=comments/'+uid+'.log', callback);
 }
}

function loadCommentForm(uid,ob){
 var loaded1 = Ajax.cloneScript("ajax.php?type=info");
 var loaded2 = Ajax.cloneScript("ajax.php?type=clone&aim=js/comment.js");
 if(loaded1 && loaded2){
  Ajax.get("ajax.php?type=commentform&UID="+uid, function(data){
   getByClass("commentFormHere",o("UID"+uid), "DIV")[0].innerHTML = data;
  });
 }
}

function loadTrackBacks(uid){ /* from v1.6.3 */
 Ajax.get("ajax.php?type=trackback&UID="+uid, function(data){
  if(o("_trackback_" + uid) == null){
   var t = d.createElement("DIV"); t.id = "_trackback_" + uid;
   o("UID"+uid).parentNode.insertBefore(t, o("UID"+uid).nextSibling);
   t.innerHTML = data;
  } else {
   o("_trackback_" + uid).style.display = o("_trackback_" + uid).style.display != "none" ? "none" : "block";
  }
 });
}

function loadPage(uid, page){
 uid = uid.replace(/d$/,'');
 Ajax.get("ajax.php?type=page&UID="+uid+"&page="+page, function(data){
  var oContent = o("UID"+uid);
  var articleContent = getByClass("article-content", oContent, "DIV")[0];
  articleContent.style.lineHeight = 1.7;
  if(getByClass("comment-expand", o("UID"+uid), "DIV")){
   data += '<p class="comment-expand" title="ここでコメントを展開します">'
        + getByClass("comment-expand", o("UID"+uid), "DIV")[0].innerHTML
        + '</p>\n';
  }
  oContent.scrollIntoView();
  if(window.opera){
   articleContent.innerHTML = '';
   articleContent.innerHTML = data;
   setTimeout(function(){ cornerPlay(articleContent)}, 50);
  } else {
   articleContent.innerHTML = data;
   cornerPlay(articleContent);
  }
  if(moz) hackFirefoxToolTip();
  if(kht) {
   var scrollY = oContent.offsetTop;
   self.pageYOffset = d.documentElement.scrollTop = scrollY;
  }
 });
}

function loadArticle(uid){
 uid = uid.replace(/d$/,'');
 var pos = getElementPosition();
 var wrapperWidth = parseInt(getClientWidth()-120);
 var offsetY = 50;
 Ajax.get("ajax.php?type=article&UID="+uid, function(data){
  if(o("UID"+uid)){ setXY(o("article-wrapper"), 60, offsetY);return;}
  if(o("article-wrapper")==null){
   var articleWrapper = Element("DIV#article-wrapper", {top:50, zIndex:3000, width:wrapperWidth}, null);
   var closeImg = Element("IMG.closeButton", {top:5, width:75, height:16, cursor:"pointer"});
   var articleContent = Element("DIV#article-content-container", { position:"relative", background:"#fff" })
   closeImg.src = closeButton;
   closeImg.title = "閉じる";
   var closeImg2 = closeImg.cloneNode(true);
   articleWrapper.appendChild(closeImg);
   articleWrapper.appendChild(articleContent);
   articleWrapper.appendChild(closeImg2);
   customBox(articleWrapper);
  }
  data = data.split("$");
  var articleWrapper = o("article-wrapper");
  var closeButtons = getByClass("closeButton", articleWrapper);
  var closeImg1 = closeButtons[0], closeImg2 = closeButtons[1];
  var articleContent = o("article-content-container");
  
  articleContent.innerHTML = (data[0] + data[1] + data[0]);
  if(lt7) articleContent.style.height = "1%"; // for buggy IE6
  if(window.opera){
   setTimeout(function(){ cornerPlay(articleContent);}, 50);
  } else cornerPlay(articleContent);
  
  addEvent(closeImg1, 'click', function(){ setXY(o("article-wrapper"), 60, -100000);});
  addEvent(closeImg2, 'click', function(){ setXY(o("article-wrapper"), 60, -100000); window.scrollTo(0, 0);});
  var wrapperHeight = parseInt(getRuntimeStyle(articleWrapper, "height"));
  setXY(closeImg1, parseInt(wrapperWidth - 100), 15);
  setXY(closeImg2, parseInt(wrapperWidth - 100), parseInt(wrapperHeight - 35));
  setXY(articleWrapper, 60, offsetY);
  addEvent(articleContent, "click", function(){
   setTimeout(
    function(){
     var wrapperHeight = parseInt(getRuntimeStyle(articleWrapper, "height"));
     setXY(closeImg2, parseInt(wrapperWidth - 100), parseInt(wrapperHeight - 35));
    }, 256);
  });
  window.scrollTo(0, offsetY - 50);
  if(moz) hackFirefoxToolTip();
 });
}

function loadMedia(ob, movf, ftype){ /* from ppBlog v1.5.5 */
 var clsid;
 if(ob.href.match(/\.3gp|x\-mpeg/)){
  clsid = ie ? 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"' :
               'type="video/3gpp" data="'+movf+'"';
 } else clsid = 'type="'+ftype+'" data="'+movf+'"';
 ob.style.display = "none";
 ob.parentNode.parentNode.innerHTML += '<div class="media-part">'
  + '<h6 title="動画へのダイレクトリンク">::<a class="media-link" href="'+movf+'">'+movf+'</a>::</h6>'
  + '<object '+clsid+' width="176" height="160">'
  + '<param name="type" value="'+ftype+'" />'
  + '<param name="src" value="'+movf+'" />'
  + '<param name="autoplay" value="true" />'
  + '</object></div>';
}

function AjaxLogIn(){
 o("loginSubmit").disabled = true;
 var MD5_module = Ajax.cloneScript("./js/md5.js");
 eval(MD5_module);
 if(MD5_module){
  var auto = (o("auto_login") && o("auto_login").checked) ? 1 : 0;
  Ajax.post("admin.php", "mode=login&ID="+MD5.$(o("ID").value)+"&PWD="+MD5.$(o("PWD").value)+"&type=ajax&auto_login="+auto,
   function(to){
    if(to.match(/\.php[\?|]$/)){
     d.write('<script type="text\/javascript">window.location.href="'+to+'";<\/script>');
    } else {
     alert(to);
     o("loginSubmit").disabled = false;
     o("ID").focus();
    }
   }
  );
 } else alert("md5.js module Not Loaded!");
}

function AjaxLogInForm(){
 Ajax.cloneScript("ajax.php?type=info");
 var loginCS = new Image(14,14).src = ImagePath+"/dialog-close.png";
 var BS = Element("DIV", {width:getClientWidth(), height:getDocHeight(), backgroundColor:"#708090", zIndex:999});
 var IO = Element("DIV",
  {left:Math.round((getClientWidth()-270)/2), top:-160, width:270, height:160, zIndex:1000, textAlign:"center",
   border:"outset 3px #aaa", borderTopWidth:0, background:"#ccc url("+ImagePath+"/login-bg.png) repeat-x", padding:"20px 20px 0 20px" });
 var CS = Element("IMG", { left:287, top:4, width:14, height:14, cursor:"pointer"});
 CS.src = loginCS;  CS.title = " 閉じる ";
 
 if(typeof AUTO_LOGIN != 'undefined'){
  if(AUTO_LOGIN){
   setXY(IO, null, 0);
   setWH(IO, null, 120);
   var UI = '<h3>ppBlog*Login</h3>\n'
   + '<p style="line-height:1.3;">自動ログインが有効です.<br />ログインモードに移ります.</p>'
   + '<p><input id="auto_login" name="auto_login" type="hidden" value="1" /></p>';
  } else {
   var UI = '<h3>ppBlog*Login</h3>\n'
   + '<p><label for="ID"> I D </label><input type="text" name="ID" id="ID" /><br />'
   + '<label for="PWD">PWD </label><input type="password" name="PWD" id="PWD" /></p>'
   + (SOLO ? '<p><label for="auto_login" title="次回から自動ログインモードになります">auto-login mode?</label> '
   + '<input id="auto_login" name="auto_login" type="checkbox" value="1" /><br /></p>\n' : '\n')
   + '<p><button type="submit" id="loginSubmit">&nbsp;</button></p>';
  }
 }
 IO.innerHTML = UI;
 addEvent(CS, "click", function(){d.body.removeChild(BS);d.body.removeChild(IO);});
 
 if(ie){
  BS.style.filter = "alpha(opacity=73)";
 } else BS.style.opacity = 0.73;
 IO.appendChild(CS);
 d.body.appendChild(BS);
 d.body.appendChild(IO);
 
 if(typeof AUTO_LOGIN != 'undefined' && AUTO_LOGIN){
  Ajax.post("admin.php", "mode=login&type=auto_login&ref="+location.search, function(to){
   if(to.match(/\.php/)){
    setTimeout('window.location.replace("'+to+'");', 1200);
   }
  });
 } else {
  var fieldcss = "color:#333; height:16px; vertical-align:middle; padding:3px 8px; width:160px; border-width:0;"
              + "margin-bottom: 5px; background: transparent url("+ImagePath+"/txtfield-bg.png) no-repeat 0 0;";
  var btncss = "margin:9px auto 0 auto;width:64px; height:28px; border-width:0; cursor:pointer;"
              + "background: transparent url("+ImagePath+"/submit-button.png) no-repeat;";
  if(o("loginSubmit")) o("loginSubmit").style.cssText = btncss;
  o("ID").style.cssText = o("PWD").style.cssText = fieldcss;
  o("ID").previousSibling.style.cssText = "margin-left:15px;font: 600 15px Arial;color:#444;";
  o("PWD").previousSibling.style.cssText = "font: 600 15px Arial;color:#444;";
  o("loginSubmit").title = "Check it out";
  if(o("ID")) o("ID").focus();
  addEvent(o("loginSubmit"), "click", AjaxLogIn);
  var slideDown = function(ob){ob.style.top = (parseInt(ob.style.top)+10) +"px"};
  slideDown.loop(1, 16)(IO);
 }
}

function imagePop(e, path, w, h){
 var gcW = getClientWidth(), gcH = getClientHeight(), ratio, ow = w, oh = h, imgPop, offsetY = 160;;
 if(o("article-wrapper")!=null) setXY(o("article-wrapper"), 60, -100000);
 if(w > gcW-20 || h > gcH-70){
  ratio = Math.min((gcW-20)/w, (gcH-70)/h);
  w = Math.round(w * ratio); h = Math.round(h * ratio);
 } else ratio = 1;
 if(typeof imgPop == "undefined") imgPop = null;
 if(imgPop==null){
  var imgWrap = Element("DIV", {left:Math.round((gcW-w) / 2), top:Math.round((gcH-h-67) / 2 + getScrollY()), width:w, height:(h+45), backgroundColor:"#fff", zIndex:9999, border:"1px solid #aaa", padding: "10px"});
  var imgCaption = Element("P", {left:0, top:(h+20), width:w, textAlign:"right", font:"500 9pt/1.5 MS P Gothic", color:"navy", display:"none"});
  imgPop = Element("IMG", {left:10, top:10, width:w, height:h, backgroundColor:"#fff", border:"1px solid #aaa", display:"none"});
  var Screen = Element("DIV", {width:gcW, height:getDocHeight(), zIndex:999, background:"url("+ImagePath+"/screen.png)"});
  var loadingImg = Element("IMG", {left:Math.round(parseInt(imgWrap.style.width)/2), top:Math.round(parseInt(imgWrap.style.height)/2), backgroundColor:"#fff", zIndex:999});
  var closeImg = Element("IMG", {left:(parseInt(imgWrap.style.width)-68), top:15, width:75, height:16, cursor:"pointer"});
  closeImg.src = closeButton;
  closeImg.title = "閉じる";
  if(ratio < 1){
   var expand = Element("IMG", {left:12, top:12, width:34, height:34, zIndex:1000, cursor:"pointer", display:"none"});
   expand.src = expandImg; expand.title = " 実物大で表示 ";
   expand.on = false;
  }
  loadingImg.src = loadingAni;
  Screen.style.backgroundImage = "url("+screenBack+")";
  d.body.appendChild(Screen);

  if(ie){
   if(lt7) Screen.style.filter = "alpha(opacity=73)";
   e.target = e.srcElement;
  }
  imgWrap.appendChild(loadingImg);
  imgWrap.appendChild(imgCaption);
  imgWrap.appendChild(imgPop);
  imgWrap.appendChild(closeImg);
  d.body.appendChild(imgWrap);
  if(ratio < 1) imgWrap.appendChild(expand);
  var caption = (typeof e.target._title=="undefined") ? e.target.title : e.target._title;
  caption = caption.replace(/[\r\n]+/g,'<br/>').replace(/\s/g,'&nbsp;');
  caption = caption.split(/<br\/?>/);
  if(caption.length > 1){
   imgCaption.innerHTML = (caption[0]+"<br />"+caption[1]+" ("+ow+"×"+oh+")");
  } else imgCaption.innerHTML = '画像をクリックすると閉じます <img src="'+ImagePath+'/info2.png" width="21" height="14" alt="info" />';
  if(!kht){
   if(loadingImg.complete) { imgPop.src = path; };
   if(imgPop.complete){
    imgPop.style.display = imgCaption.style.display = "block";
    loadingImg.style.display = "none";
    if(expand) expand.style.display = "block";
   };
  } else imgPop.src = path;
  addEvent(imgPop, "load", function(){
   imgPop.style.display = imgCaption.style.display = "block";
   loadingImg.style.display = "none";
   if(expand) expand.style.display = "block";
  });
  addEvent(closeImg, "click", function(){
   if(o("article-wrapper")!=null) setXY(o("article-wrapper"), 60, offsetY);
   d.body.removeChild(imgWrap);
   d.body.removeChild(Screen);
   imgPop = null;
  });
  addEvent(imgPop, "click", function(){
   if(o("article-wrapper")!=null) setXY(o("article-wrapper"), 60, offsetY);
   d.body.removeChild(imgWrap);
   d.body.removeChild(Screen);
   imgPop = null;
  });
  if(ratio < 1){
   addEvent(expand, "click", function(){
    if(expand.on==false){
     setXY(imgWrap, 0, getScrollY());
     setWH(imgWrap, ow+3, oh);
     setWH(imgPop, ow, oh);
     setXY(closeImg, (parseInt(imgWrap.style.width)-69), null);
     expand.src = unexpandImg; expand.title = " ウィンドウのサイズに合わせる ";
     expand.on = true;
    } else {
     setXY(imgWrap, Math.round((gcW-w) / 2), Math.round((gcH-h-67) / 2 + getScrollY()));
     setWH(imgWrap, w, h+45);
     setWH(imgPop, w, h);
     setXY(closeImg, (parseInt(imgWrap.style.width)-66), null);
     expand.src = expandImg; expand.title = " 実物大で表示 ";
     expand.on = false;
    }
   });
  } //#ratio==1
  imgPop.title = "マウスクリックで閉じます";
 } //#imgPop==null
}

function initCSSHover(){
 if(ie){
  if(o("theme-selector")){
   var root = o("theme-selector");
   addEvent(root, "mouseover", tsOver);
   addEvent(root, "mouseout", tsOut);
  }
 }
}
function tsOver(){this.className+=" over";}
function tsOut(){this.className=this.className.replace(/ over/, "");}
function noCSS(){
 if(d.styleSheets) foreach(d.styleSheets, function(ob){ob.disabled = true;});
 foreach(o("$link"), function(ob){if(ob.rel.match(/stylesheet/i))ob.disabled=true;});
 foreach(o("$*"), function(ob){ob.style.cssText="";});
}
function addEvent(obj, evType, fn){
 if(!obj["_"+evType]){
  obj["_"+evType] = [];
  if(obj["on" + evType] != null) obj["_"+evType].push(obj["on" + evType]);
  obj["on" + evType] = function(e){
   e = e || window.event;
   for(var i in this["_"+e.type]) this["_"+e.type][i].apply(this,[e]);
  }
 } else for(var i in obj["_"+evType]) if(obj["_"+evType][i]===fn) return;
 obj["_"+evType].push(fn);
 obj = null; // necessary for IE memory-leak
};
function removeEvent(obj, evType, fn){
 if(obj["_"+evType]){
  for(var i in obj["_"+evType]){
   if(obj["_"+evType][i]===fn) delete obj["_"+evType][i];
  }
 }
};

function o(a){
 if(typeof a == "object") return a;
 if(typeof a == "string"){
  if(a.match(/(^[a-zA-Z0-9_-]+$)/)){ // Unique ID
   return d.getElementById(a);
  } else if(a.match(/([a-zA-Z0-9\*]*?)\.([a-zA-Z0-9_-]+$)/)){ // tagName.className
   return getByClass(RegExp.$2, d, RegExp.$1);
  } else if(a.match(/^\$/)) return d.getElementsByTagName(a.slice(1));
 }
 return null;
};

function Element(tag, prop, parent){
 var el = d.createElement(tag.split(/[#\.]/)[0]);
 var es = el.style;
 
 es.position = "absolute";
 es.top = 0; es.left = 0;
 es.padding = 0; es.margin = 0;
 es.width = el.offsetWidth || "auto" || 0;
 es.height = el.offsetHeight || "auto" || 0;
 if(prop){
  for (var i in prop){
   if(/top|right|bottom|left|width|height/.test(i)){
    if(/px|%/.test(prop[i])) es[i] = prop[i]; else es[i] = prop[i] + "px";
   } else es[i] = prop[i];
  }
 }
 if(es.left=="" && es.right=="") es.left = 0;
 if(es.top=="" && es.bottom=="") es.top = 0;
 if(tag.split(/#/)[1]) el.id = tag.split(/#/)[1];
 if(tag.split(/\./)[1]) el.className = tag.split(/\./)[1];
 if(parent) parent.appendChild(el); else d.body.appendChild(el);
 return el;
}

function setXY(ob, x, y){
 if(!ob) return;
 ob.style.position = "absolute";
 if(x != null) ob.style.left = parseInt(x) + "px";
 if(y != null) ob.style.top = parseInt(y) + "px";
}

function setWH(ob, w, h){
 if(!ob) return;
 if(w != null) ob.style.width = parseInt(w) + "px";
 if(h != null) ob.style.height = parseInt(h) + "px";
}

function getRuntimeStyle(ob, style, css){
 var val = null;
 if(w3c){
  style = style.replace(/([A-Z])/g,"-$1").toLowerCase();
  if(css) val = ob.style[style] || 'auto';
  val = (val=='auto') ? 'auto' : d.defaultView.getComputedStyle(ob, null).getPropertyValue(style);
 } else if(ob.currentStyle){
  if(css){
   val = ob.currentStyle[style];
  } else {
   if(style=='width'){
    val = ob.offsetWidth;
   } else if(style=='height'){
    val = ob.offsetHeight;
   } else val = ob.currentStyle[style];
  }
 } else val = ob.style[style];
 return val;
}

function getByClass(className, pElement, tagName){
 var cls = gets = []; pElement = pElement || d;
 var obs = pElement.getElementsByTagName((!tagName?"*":tagName));
 var i=0, l=obs.length, j, k;
 while(i < l){
  cls = obs[i].className.split(/\s+/);
  j = 0; k = cls.length;
  while( j < k){
   if(cls[j]==className){
    gets.push(obs[i]); break;
   } j++;
  } i++;
 }
 return gets.length > 0 ? gets : null;
}

Function.prototype.await = function(ms){
 var self = this;
 var f = function(){
  var a = arguments, t = this;
  var callee = function(){self.apply(t, a);};
  setTimeout(callee, ms);
 };
 return f;
}

Function.prototype.loop = function(ms, limit){
 var count = 0, self = this;
 return function(a){
  if(limit <= count) return;
  count++;
  self.await(ms)(a);
  arguments.callee.await(ms)(a);
 }
}

function foreach(obs, fn){
 if(obs && obs.length){
  var i = 0, l = obs.length;
  while(i < l) fn.call(this, obs[i], i++, l);
 }
}

function $HEX(ob, color){
 color = color || 'backgroundColor';
 var color2hex = {
aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"778899",lightslategrey:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"
};
 if(ob) color = getRuntimeStyle(ob, color);
 color = (color==''||color=='transparent'||color=='inherit') ? "rgb(246, 245, 247)" : color;
 if(color.toLowerCase().match(/#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/)){
  return [ Number(hex2dec(RegExp.$1)), Number(hex2dec(RegExp.$2)), Number(hex2dec(RegExp.$3)) ];
 }
 if(color.toLowerCase().match(/#([0-9a-f]{3})/)){
  color = RegExp.$1 + RegExp.$1;
  return [ hex2dec(color.slice(0,2)), hex2dec(color.slice(2,4)), hex2dec(color.slice(4,6)) ];
 }
 if(color.toLowerCase().match(/rgb\((\d+?), (\d+?), (\d+?)\)/)){
  return [ Number(RegExp.$1), Number(RegExp.$2), Number(RegExp.$3) ];
 }
 
 if(color.toLowerCase().match(/(\w+)/)){
  for (var colorName in color2hex){
   if(colorName==RegExp.$1){
    color = color2hex[colorName];
    return [ hex2dec(color.slice(0,2)), hex2dec(color.slice(2,4)), hex2dec(color.slice(4,6)) ];
   }
  }
 }
 return [ Number(246), Number(245), Number(247) ];
}

function dec2hex(d){ return (d < 16) ? ("0" + Number(d).toString(16)) : Number(d).toString(16);}
function hex2dec(h){ return Number(parseInt(h, 16));}

var Cookie = {
 set : function(name, value, days){
  days = days || 30;
  var expire = new Date(); expire.setTime(expire.getTime() + (days*60*60*24*1000));
  d.cookie = name + "=" + escape(value) + "; expires=" + expire.toGMTString() + "; path=/";
 },
 get : function(name){
  var x, c = d.cookie.split(";");
  for(var i = 0, l = c.length; i < l; i++){
   x = c[i].indexOf("=");
   if(c[i].substr(0, x)==name || c[i].substr(0, x)==" " + name){
    return unescape(c[i].substr(x + 1));
   }
  }
  return null;
 },
 del : function(name) { Cookie.set(name,"",-1); }
}

var DOM = { /* window.onload alternative ref http://dean.edwards.name/weblog/2006/06/again/ */
 complete : function(){
  if(arguments.callee.done) return;
  arguments.callee.done = true;
  if(typeof _timer_DOM != 'undefined'){
   clearInterval(_timer_DOM);
   _timer_DOM = null;
  }
  DOM.onload();
 },
 check : function(){
  if(d.addEventListener){
   d.addEventListener("DOMContentLoaded", DOM.complete, false);
  }
  if(kht){ // safari
   var _timer_DOM = setInterval(function(){if(d.readyState.match(/loaded|complete/))DOM.complete();}, 50);
  }
   /*@cc_on @*/
   /*@if (@_win32)
    d.write('<script id="_decoy_" defer src="javascript:void(0)"><\/script>');
    o("_decoy_").onreadystatechange = function(){if(this.readyState=='complete')DOM.complete();};
   /*@end @*/
  addEvent(window, "load", DOM.complete);
 },
 onload : function(){}
}
DOM.check();

DOM.onload = function(){
 if(lt7) initCSSHover();
 if(moz) hackFirefoxToolTip();
 var ids = "menu,recently,tags,comments,categories,trackbacks,archives,others";
 foreach(ids.split(/,/), function(id){
  var ob = o(id);
  if(ob != null && ob.firstChild){
   addEvent(ob.firstChild.firstChild, "click", function(){ toggleBox(this); });
   var state = Cookie.get("PPBLOG_SIDEBAR_"+id.toUpperCase()+"_STATE");
   if(state != null) toggleBox(ob.firstChild.firstChild, state);
  }
 });
 cornerPlay(d);
}
