var swirlingElems = new Array();
var col = new Array(16);
var timeOutSet = false;

col[0] = "#ffffff";
col[1] = "#eeeeee";
col[2] = "#dddddd";
col[3] = "#cccccc";
col[4] = "#bbbbbb";
col[5] = "#aaaaaa";
col[6] = "#999999";
col[7] = "#888888";
col[8] = "#777777";
col[9] = "#666666";
col[10] = "#555555";
col[11] = "#444444";
col[12] = "#333333";
col[13] = "#222222";
col[14] = "#111111";
col[15] = "#000000";

function stopColorSwirl(elem) {
  for (i=0; i < swirlingElems.length; i++) {
      if (swirlingElems[i].element ==  elem) {
           swirlingElems[i].direction = -1;
	   return ;
      }
  }
}
function startColorSwirl(elem) {
   for (i = 0; i < swirlingElems.length; i++) {
     if (swirlingElems[i].element == elem){
       swirlingElems[i].direction = 1;
       return;
     }
   }
   new Swirler(elem);
   if (!timeOutSet)  window.setTimeout('swirlTimer()',20);
   timeOutSet = true;
}
function Swirler(elem) {

   this.element = elem;
   this.colorNum = 0;
   this.direction = 1;
   swirlingElems[swirlingElems.length] = this;
}
function swirlTimer() {
   var i;

   for (i = 0; i < swirlingElems.length; i++) {
      var elem = swirlingElems[i];
      if (elem.direction == 1) {
            elem.colorNum ++;
	    if (elem.colorNum > 15) {elem.colorNum = 15;    ;}
      } else {
            elem.colorNum --;
	    if (elem.colorNum < 0) {elem.colorNum = 0;	    }
      }	    
      elem.element.style.color=col[elem.colorNum];
    
   }  window.setTimeout('swirlTimer()',40);
   timeOutSet = true;
}







