// Special effects for nodes handled with spawn.js functions
// requires rgb.js for colour handling
// Written by David Turover, Nov. 2003. Public domain. 

function fade(id){
	var node = document.getElementById(id);
	if(node == null){
		//alert("No node with id " + id);
		return null; }
	if(!node.style.color){
		// Lack of color defaults to null string,
		// which breaks this funtion.
		// detect and correct for this 
		node.style.color = "#000000";
	}
	var c = RGBArray(node.style.color);
	if(c == null){
		 alert("Could not get RGBArray from node " + id);
		 return null; }
	var r = parseInt(c[1]);
	var g = parseInt(c[2]);
	var b = parseInt(c[3]);
	//alert("pre: " + r + "," +  g + "," + b);
	if((r += 0x40) > 0xff){ r = 0xff; }
	if((g += 0x40) > 0xff){ g = 0xff; }
	if((b += 0x40) > 0xff){ b = 0xff; }
	//alert("mid: " + r + "," +  g + "," + b);
	if(r >= 0xff && g >= 0xff && b >= 0xff){
		//alert("Killing node");
		killNode(node);
	} else {
		//alert("Fading...");
		node.style.color = "rgb(" + r + "," + g + "," + b + ")";
		//alert("post: "+ r + "," +  g + "," + b);
		//alert(c);
		triggers[id] = setTimeout("fade(" + id + ")", 133);
	}
	return null;
}

