function setOpacity(obj, opacity)
{
	// check first if the object even exists
	if(!obj)
		return false;
	opacity = (opacity == 100)?99.999:opacity;
	
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	
	// Safari < 1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}
/*----------------------*/

// opacity is the starting opacity
function fadeIn(objId,opacity,target,speed)
{
	clearTimeout(fadeInTimer);
	if (document.getElementById)
	{
		obj = document.getElementById(objId);
		if (opacity <= target)
		{
			setOpacity(obj, opacity);
			opacity += 10;
			var fadeInTimer = window.setTimeout("fadeIn('"+objId+"',"+opacity+","+target+","+speed+")", speed);
		}
		else
		{
			// time to remove the loading graphic from the background
			// do this because in Firefox, the loading graphic eats up a lot of cpu time when something covers it *shrug*
			var parent = obj.parentNode;
			if(parent && parent.nodeType == 1)
			{
				if(parent.style.backgroundImage != "url()")
					parent.style.backgroundImage = "url()";
			}
		}
	}
}
/*----------------------*/

function fadeOut(objId,opacity,speed,remove)
{
	clearTimeout(fadeOutTimer);
	if (document.getElementById)
	{
		obj = document.getElementById(objId);
		if (opacity >= 0)
		{
			setOpacity(obj, opacity);
			opacity -= 10;
			var fadeOutTimer = window.setTimeout("fadeOut('"+objId+"',"+opacity+","+speed+","+remove+")", speed);
		}
		else
		{
			if(!remove)
				obj.style.display = "none";
			else
			{
				var parentNode = obj.parentNode;
				parentNode.removeChild(obj);
				return true;
			}
		}
	}
}
/*----------------------*/
