var Colours = new Array("#eaeaea","#e2e2ef","#dbdbf4","#d3d3fa","#ccccff"); //"#e1e1f0",,"#ccccff"
var toutRef;                      // a timer reference
var rootColour = "transparent";   // colour to revert to.
var chamInt = 50;                 // dissolve speed - lower=faster
var mssg = "";

function selItem(id) {
  var elem = "m" + id;
  // some clearing up in case something is still chameleon-ing
  if (toutRef) {
    clearTimeout(toutRef);
  }

  if (document.getElementById) {
    var myObj = document.getElementById(elem);
    var cmd = "Chameleon(" + id + ",0)";
    toutRef = setTimeout(cmd,chamInt);
  }
}

function DeselItem(id) {
  var elem = "m" + id;
  // some clearing up in case something is still chameleon-ing

  //mssg += "\n" + id + " going OFF.";
  if (toutRef) {
    clearTimeout(toutRef);
  }
  if (document.getElementById) {
    var myObj = document.getElementById(elem);
    myObj.style.backgroundColor = rootColour;
  }
}

function Chameleon(id,i) {
  var elem = "m" + id;
  var myObj = document.getElementById(elem);
  var j = i + 1;
  var cmd = "Chameleon(" + id + "," + j + ")";
  if (i < Colours.length) {
    myObj.style.backgroundColor = Colours[i];
    toutRef = setTimeout(cmd,chamInt);
  }
}

function Reporter() {
  alert(mssg);
}

function ClearMssg() {
  mssg = "";
}
