/*
  HightLight
    by sinara@blade.nagaokaut.ac.jp
    2003.01.26
*/

red = "#ff0000";
yellow = "#ffff00";
lightgreen = "#90ee90";
greenyellow = "#adff2f";
//Pastelgreen = "#ccffcc";
Pastelgreen = "#ddffcc";

mark = yellow;
done = Pastelgreen;
jump = red
hline = null;

function chk() {
  var name = navigator.appName;
  var ver = navigator.appVersion;
  if (name.charAt(0) == "M") {
    if (ver.charAt(0) >= 5 ||
        ver.indexOf(" 5.5") >= 0 ||
        ver.indexOf(" 6") >= 0
       )
      return(true);
    return(false);
  } else if (name.charAt(0) == "N") {
    if (ver.charAt(0) >= 5)
      return(true);
    return(false);
  } else {
    return(false);
  }
}

function nextHilight() {
  if (hline) {
    hilight(hline + 1);
    if ((e = document.getElementById("id" + hline)) && parent)
        parent.frames[1].location.href = e.toString()
  }
}

function prevHilight() {
  if (hline && hline > 1) {
    hilight(hline - 1);
    if ((e = document.getElementById("id" + hline)) && parent)
        parent.frames[1].location.href = e.toString()
  }
}

function hilight(x) {
  if (!chk()) return;
  if (hline) {
    var e = null;
    e = document.getElementById("id" + hline);
    if (e) {
      e.style.backgroundColor = done;
//      moveColor(e, null, done, 2, 50);
    }
  }
  if (x) {
    f = document.getElementById("id" + x);
    if (f) {
      f.style.backgroundColor = mark;
    } else {
      if (e) {
        e.style.backgroundColor = red;
//	moveColor(e, jump, done, 1, 10);
      }
    }
    hline = x;
  }
}

function hilightInit(x) {
  if (!chk()) return;
  var hline0 = x;
  if (h = location.href.match(/#.+/)) {
    if (h = h.toString().match(/\d+/)) {
      hline0 = h.toString();
     }
  }
  normal = document.bgColor;
  hilight(hline0);
}

function colorArray(str) {
  if (m = str.match(/rgb\((\d+),(\d+),(\d+)\)/))
    return Array(parseInt(m[1]), parseInt(m[2]), parseInt(m[3]));
  else if (m = str.match(/#(..)(..)(..)/))
    return Array(parseInt(m[1], 16), parseInt(m[2], 16), parseInt(m[3], 16));
  else
    return null;
}

function moveC(){
  if (inter <= dim) {
    var rgb = Array();
    for(var j = 0; j < 3; j++) {
      rgb.push(Math.round((colora0[j]*(dim-inter) + colora[j]*inter)/dim));
    }
    elem.style.backgroundColor = "rgb(" + rgb + ")";
    inter++;
  } else {
    clearInterval(Iter)
  }
}

function moveColor(e, c0, c, msec, x) {
  bgcolor = e.style.backgroundColor || document.bgColor || "#ffffff";
  if (!c0) {
    c0 = bgcolor;
  }
  dim = x;
  inter = 0;
  elem = e;
  colora0 = colorArray(c0);
  colora = colorArray(c);
  Sec = msec * 1000;
  Iter = setInterval(moveC, Sec/dim);
}

