/**
 * Author: Lachlan Hunt
 * Date: 2005-11-24
 * Version: 1.0
 *
 * Licence: Public Domain
 * Attribution is considered ethical, but not required.
 */

function fadeStep(element,pallet,step,delay) {
	return function() {
		if (step < pallet.length) {
			element.style.backgroundColor = pallet[step++].hex();
			setTimeout(fadeStep(element, pallet, step, delay),delay);
		}
	}
}

function fade(element,startColor,endColor) {
	var colEnd = (endColor) ? new Color(endColor) : new Color("#FFFFFF");
	var steps = parseInt("30");
	var delay = parseInt("0");
	var element = document.getElementById(element) ? document.getElementById(element) : document.getElementById("pagearea");
	var colStart = (startColor) ? new Color(startColor) : new Color("#3366FF");
	var pallet = colStart.blend(colEnd, steps);	
	setTimeout(fadeStep(element, pallet, 0, delay), delay);
}