
//スクロールバーの色変化
var hexStr = '0123456789abcdef';
function byteToHex(b) {
  return hexStr.charAt(Math.floor(b / 16)) + hexStr.charAt(b % 16);
}
function hexToByte(h) {
  return hexStr.indexOf(h.charAt(0)) * 16 + hexStr.indexOf(h.charAt(1));
}
function GetMiddleColor(c1,c2,p) {
  c1=hexToByte(c1);
  c2=hexToByte(c2);
  return Math.floor((c1-c2)*p/100)+c2;
}
function BGCFA(id,s,e,m,timing,p) {
  if (!m) m=0;
  if (!timing) timing=20;
  if (!p) p=100;
  if ((document.all)||(document.getElementById)) {
    c=(document.all)?document.all(id).style:document.getElementById(id).style;
    r=GetMiddleColor(s.substring(1,3),e.substring(1,3),p);
    g=GetMiddleColor(s.substring(3,5),e.substring(3,5),p);
    b=GetMiddleColor(s.substring(5,7),e.substring(5,7),p);
    cc='#'+byteToHex(r)+byteToHex(g)+byteToHex(b);
    (m==0)?c.backgroundColor=cc:c.color=cc;
    if (--p==0) {
      p=100; b=s; s=e; e=b;
    }
    setTimeout('BGCFA("'+id+'","'+s+'","'+e+'",'+m+','+timing+','+p+')',timing);
  }
}
function fadeSB(id,s,e,tm,p) {
  if (document.all) {
    if (!p) p=100;
    r=GetMiddleColor(s.substring(1,3),e.substring(1,3),p);
    g=GetMiddleColor(s.substring(3,5),e.substring(3,5),p);
    b=GetMiddleColor(s.substring(5,7),e.substring(5,7),p);
    cc='#'+byteToHex(r)+byteToHex(g)+byteToHex(b);
    c=document.all(id).style;
    c.scrollbarBaseColor=cc;
    if (--p==0) {
      p=100; b=s; s=e; e=b;
    }
    setTimeout('fadeSB("'+id+'","'+s+'","'+e+'",'+tm+','+p+')',tm);
  }
}

