/*+--------------------------------------------------------------------------+
  | Title       : Rainbow-Text                                               |
  | Author      : Bach Quang Ha                                              |
  | Website     : http://www.hqbach.us                                       |
  | Last Modify : 04/15/2003                                                 |
  | Note        : Free to use for any purpose as long as these comments still|
  |             : attached                                                   |
  +--------------------------------------------------------------------------+*/

var soc, clrRGB, TimerID, i, k, begred, beggreen, begblue, endred, endblue, endgreen, aveblue, avegreen, avered, k2, beg, end;

function RT_colorIt()
{
  beg = "ffffff"; // beginning color
  end = "eecc00"; // ending color
  i   = 25; // number of color change in each period (Default = 25)
  soc = 30; // speed of change (Default = 50)

  // no change after this line
  k2  = 0;
  k   = 0;

  // parse the input strings for color information
  begred    = parseInt(beg.substring(0,2),16);
  beggreen  = parseInt(beg.substring(2,4),16);
  begblue   = parseInt(beg.substring(4,6),16);

  endred    = parseInt(end.substring(0,2),16);
  endgreen  = parseInt(end.substring(2,4),16);
  endblue   = parseInt(end.substring(4,6),16);

  // determine size of step
  aveblue   = (endblue-begblue)/i;
  avegreen  = (endgreen-beggreen)/i;
  avered    = (endred-begred)/i;

  // animation
  TimerID  = setInterval("RT_colorMe()", soc);
}

function RT_colorMe()
{
  colorText.style.color = RT_makeColor();
}

function RT_makeColor()
{
  // trace the motion
  if (k2  == 0)   k++;
  if (k2  == 1)   k--;
  if (k   == i-1) k2 = 1;
  if (k   == 0)   k2 = 0;

  // get the current color
  red   = Math.round(begred+k*avered).toString(16);
  green = Math.round(beggreen+k*avegreen).toString(16);
  blue  = Math.round(begblue+k*aveblue).toString(16);

  if (blue.length ==1) blue='0'+blue;
  if (red.length  ==1) red='0'+red;
  if (green.length==1) green='0'+green;

  // return exact value
  clrRGB = '#'+red+green+blue;
  return clrRGB;
}
