var list; // global list variable cache
var tickerObj; // global tickerObj cache
var hex = 1;
var interval = 5; // interval in seconds
var fadeSpeed = 40; // fade speed, the lower the speed the faster the fade.  40 is normal.

function initScript() {
	initialiseList('tic');
}

function fadeText(divId) {
	if(tickerObj) {
		if(hex<99) {
			hex+=2; // increase color darkness			
			if (hex == 100 && (navigator.userAgent.indexOf('Gecko') != -1 && navigator.userAgent.indexOf('Safari') == -1)) hex = 99.99
			tickerObj.style.opacity = tickerObj.style.MozOpacity = tickerObj.style.KhtmlOpacity = hex / 100;
			tickerObj.style.filter = "alpha(opacity:"+hex+")"; 
			setTimeout("fadeText('" + divId + "')", fadeSpeed); 
		} else {
			hex=1; //reset hex value
		}
	}
}

function initialiseList(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);
		}
	}
	if (list.length != 0) {
		run(divId, 0);
	}
}

function run(divId, count) {
	//fadeText(divId);
	list[count].style.display = "block";
	if(count > 0) {
		list[count-1].style.display = "none";
	} else {
		list[list.length-1].style.display = "none";
	}
	count++;
	if(count == list.length) {
		count = 0;
	}
	window.setTimeout("run('" + divId + "', " + count+ ")", interval*1000);
}