colorAnimation = new Array();
animationPointer = 0;

dom = (document.getElementById);
ie = (document.all);

function fade(from,to,steps,who,when)
	{
	from = hex2rgb(from);
	to   = hex2rgb(to);

	diff = new Array( (to[0]-from[0]), (to[1]-from[1]), (to[2]-from[2]) );
	
	
	for(i=0;i<steps;i++)
		{
		colorAnimation[i] = new Array();
		for(color=0;color<3;color++)
			{
			colorAnimation[i][color] = Math.round( from[color] + ((diff[color]/steps)*i) );
			}
		}

	setTimeout("animate('" + who + "')", when*1000);
	
	}

function hex2rgb(color)
	{
	r = color.substr(0,2); r = parseInt(r,16);
	g = color.substr(2,2); g = parseInt(g,16);
	b = color.substr(4,2); b = parseInt(b,16);
	return new Array(r,g,b);
	}

function animate(who)
	{
	if(dom)
		{
		eval('obj = document.getElementById("' + who + '").style')
		}
	else if(ie)
		{
		eval('obj = document.all.' + who + '.style')
		}

	obj.color =
		"rgb("+colorAnimation[animationPointer][0]+","
		      +colorAnimation[animationPointer][1]+","
				+colorAnimation[animationPointer][2]+")";
	
	animationPointer++;
	
	if(animationPointer<colorAnimation.length) setTimeout("animate('" + who + "')", 75);
	}
