function rotateConfig(id)
{
	this.id = id;
	this.texts = new Array();
	this.rotateTime = 5000;
	this.startColor = new Array(255, 255, 255);
	this.endColor = new Array(0, 0, 0);
	this.fadeLinks = 1;
	this.stepDelay = 40;
	this.maxSteps = 30;
}

function rotate(config)
{
	//erster Aufruf aus DynamicQuery.ascx.cs ohne Verzögerung
	if(config.texts.length > 1)
	{
		var aktText = config.texts.shift();
		config.texts.push(aktText);
		
		document.getElementById(config.id).style.color = "rgb(" + config.startColor[0] + ", " + config.startColor[1] + ", " + config.startColor[2]+")";
		document.getElementById(config.id).innerHTML = aktText;
		colorFade(config, 1);
		
		t = setTimeout(function(){rotate(config)}, config.rotateTime);
	}
}

function colorFade(config, step)
{
	if (step <= config.maxSteps)
	{	
		document.getElementById(config.id).style.color = getStepColor(config, step);
		if (config.fadeLinks)
			linkColorChange(config, step);
		step++;
		fadeCounter = setTimeout(function(){colorFade(config, step)}, config.stepDelay);
	}   
}

function linkColorChange(config, step)
{
	var obj = document.getElementById(config.id).getElementsByTagName("a");

	if (obj.length > 0)
	{
		for (i = 0; i < obj.length; i++)
			obj[i].style.color = getStepColor(config, step);
	}
}

function getStepColor(config, step)
{
	var diff
	var newcolor = new Array(3);

	for(var i = 0; i < 3; i++)
	{
		diff = (config.startColor[i] - config.endColor[i]);
		if (diff > 0)
		{
			newcolor[i] = config.startColor[i]-(Math.round((diff/config.maxSteps))*step);
		} 
		else 
		{
			newcolor[i] = config.startColor[i]+(Math.round((Math.abs(diff)/config.maxSteps))*step);
		}
	}
	return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}
