// JavaScript Document

// Copyright (C) 伊織舞也 (http://www.losttechnology.jp/)
// 著作権表示を消さなければご自由にお使いください
function IntRandom(max) {
  return Math.floor(Math.random()*max);
}
var hexStr = '0123456789abcdef';
function byte2Hex(b) {
  return hexStr.charAt(Math.floor(b / 16)) + hexStr.charAt(b % 16);
}
function RandomColor(id,timing,m) {
  if ((document.all)||(document.getElementById)) {
    m=(!m)?0:1;
    c=(document.all)?document.all(id).style:document.getElementById(id).style;
    cc='#'+byte2Hex(IntRandom(256))+byte2Hex(IntRandom(256))+byte2Hex(IntRandom(256));
    switch(m) {
      case(0):
        c.color=cc;
        break;
      case(1):
        c.backgroundColor=cc;
        break;
    }
    setTimeout('RandomColor("'+id+'",'+timing+','+m+')',timing);
  }
} 
function ColorMessage(id) {
  if ((document.all)||(document.getElementById)) {
    if (document.all) c=document.all.item(id)
    else c=document.getElementById(id);
    c.style.color='#'+byte2Hex(IntRandom(256))+byte2Hex(IntRandom(256))+byte2Hex(IntRandom(256));
    setTimeout('ColorMessage(\''+id+'\')',300);
  }
} 
function BGColorMessage(id) {
  if ((document.all)||(document.getElementById)) {
    if (document.all) c=document.all.item(id)
    else c=document.getElementById(id);
    c.style.backgroundColor='#'+byte2Hex(IntRandom(256))+byte2Hex(IntRandom(256))+byte2Hex(IntRandom(256));
    setTimeout('BGColorMessage(\''+id+'\')',300);
  }
}