var delay = 150;
var delay_hide = 100; // time the text is hidden
var delay_show = 1000; // time the text is shown

var currentcolor = 0;
var direction = 1;
var timer = null; // preset to null!

function RunBanner(sID, cText){
	// start de timer voor de array
	var cCommand = "BannerStep('" + sID + "', '" + cText + "')";
	timer = setInterval(cCommand, delay);
}

function BannerStep(sID, cText) {

	var o = document.getElementById(sID) ;//eval(sID)
	var aText = cText.split(",");
	if (o.innerHTML == ""){
		SwitchText(o, aText);
	}

	var cCommand = "BannerStep('" + sID + "', '" + cText + "')";

	clearInterval(timer);

	if (direction == 1 && currentcolor == 15) {
		// max kleur bereikt (zwart): richting omdraaien, tijdsduur aanpassen
		direction = -1;

		timer = setInterval(cCommand, delay_show);
		return;
	}
	else if (direction == -1 && currentcolor == 0){
		// min kleur bereikt (wit) : richting omdraaien, tekst wisselen, tijdsduur aanpassen
		direction = 1;

		if (aText.length > 1) {
			SwitchText(o, aText);
		}

		timer = setInterval(cCommand, delay_hide);
		return;
	}
	else{
		// standaard optie: kleur aanpassen, tijdsduur op standaard
		var iColor = (15 - currentcolor) * 1118481;

		currentcolor += direction;
		timer = setInterval(cCommand, delay);

		o.style.color = iColor.toString();

	}
}

function SwitchText(obj, aText) {
	var CurrentText = obj.innerHTML;
	// Bepaal welk element er nu actief is
	_currenttext = -1;
	for(var i=0; i < aText.length & _currenttext < 0; i++) {
		if (CurrentText == aText[i]) {
			_currenttext = i;
		}
	}
	// activeer de volgende tekst in de array
	_currenttext ++;

	if (_currenttext >= aText.length) _currenttext = 0;

	SetText(obj, aText[_currenttext]);
}
function SetText(oBanner, cText){
	// aanpassen tekst voor IE/Netscape
	if (document.all) oBanner.innerHTML = cText; // document.all = IE only
	if (document.layers) {document.oBanner.document.write(cText); document.oBanner.document.close(); } // document.layers = Netscape only
}