/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: James Crooke :: http://www.cj-design.com */

var interval = 4; // interval in seconds
var fadeSpeed = 100; // fade speed, the lower the faster

var list;
var tickerObj;
var hex = 128;

function fadeText(divId) {
  if(tickerObj)
  {
    if(hex < 255) {
      hex += 43; // increase color lightness
			if(hex > 255) hex = 255;
      tickerObj.style.color = "rgb("+hex+","+hex+","+hex+")";
      setTimeout("fadeText('" + divId + "')", fadeSpeed); 
    } else
      hex = 128; //reset hex value
  }
}

function fade(divId) {
  tickerObj = document.getElementById(divId);
  list = tickerObj.childNodes;
  for (var i=0; i<list.length; i++) 
	{
    var node = list[i];
    if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) tickerObj.removeChild(node);
  }
  run(divId, 0);
}

function run(divId, count) {
  if(count > 0)
	{
    list[count-1].style.display = "none";
	} else {
    list[list.length-1].style.display = "none";
	}
  list[count].style.display = "block";	
  fadeText(divId);
  if(++count == list.length) count = 0;
  if(list.length > 1) window.setTimeout("run('" + divId + "', " + count+ ")", interval*1000);
}
