// JavaScript Document

Effects = new Object();

Effects.fade = function(id, opacStart, opacEnd, millisec, callback){
	
	Effects.changeOpacity(opacStart, id);
	
	var speed = Math.round(millisec/100);
	var timer = 0;
	
	if(opacStart > opacEnd)
	{
		var steps = opacStart - opacEnd;
		if (steps > 20) 
			steps = 20;
		var stepSize = opacStart / steps;
		speed = Math.round(millisec / steps); 
		//for(var i=opacStart; i>=opacEnd; i--)
		for(var i=opacStart; i>=opacEnd; i = i - stepSize)
		{
			setTimeout("Effects.changeOpacity("+ i +", '"+ id +"', "+ opacEnd +", "+ callback +")", (timer*speed));
			timer++;
		}
	}
	else if(opacStart < opacEnd)
	{
		var steps = opacEnd - opacStart;
		if (steps > 20) 
			steps = 20;
		var stepSize = opacEnd / steps;
		speed = Math.round(millisec / steps); 
		//for(var i=opacStart; i<=opacEnd; i++)
		for(var i=opacStart; i<=opacEnd; i = i + stepSize)
		{
			setTimeout("Effects.changeOpacity("+ i +", '"+ id +"', "+ opacEnd +", "+ callback +")", (timer*speed));
			timer++;
		}
	}
}

Effects.changeOpacity = function(opacity, id, endPoint, callback)
{
	p = document.getElementById(id);
	el = p;

/*el = p.firstChild;
	while (el){
		if(el.nodeType != 3){*/
			el.style.opacity = (opacity / 100);
			el.style.MozOpacity = (opacity / 100);
			el.style.KhtmlOpacity = (opacity / 100);
			if (opacity == 100)
				el.style.filter = "";
			else
				el.style.filter = "alpha(opacity=" + opacity + ")";
		/*}
		
		el = el.nextSibling;
	}*/
	
  if(opacity == endPoint && callback != null)
  {
		callback.call();
  }
}
