
	function toObject ( something )	{
		if ( typeof( something ) == 'string' )
			return document.getElementById ( something );
		if ( typeof( something.nodeName ) != 'undefined' )
			return something;
		return null;
	}
	
	function fadeElement ( elem, nAlpha, nStep, nInterval, onCallBack )	{
		elem = toObject( elem );
		var style = elem.style;
		var actualAlpha = ( typeof( style.opacity ) != "undefined" ? style.opacity : 1 );
		var nDir = 0;
		var nTotal = 0;
		
		clearTimeout( elem.fadeTimeOut );
		
		if( nStep <= 0 )
			nStep = 0.05;
		else if( nStep > 1 )
			nStep /= 100;
		
		if( nAlpha < 0 )
			nAlpha = 0;
		else if( nAlpha > 1 )
			nAlpha /= 100;
		
		nTotal = Math.abs( Number( nAlpha ) - Number ( actualAlpha ) );
		
		if ( nTotal > 0 )	{
			if ( nTotal < Math.abs( nStep ) + 0.01 )
				nStep = nTotal;
			
			nDir = ( Number( nAlpha ) - Number ( actualAlpha ) ) >= 0 ? 1 : -1;
			
			actualAlpha = ( Number( actualAlpha ) + Number( nStep * nDir ) );
			setElementOpacity( elem, actualAlpha );
		}

		if ( actualAlpha == nAlpha )	{
			if ( typeof( onCallBack ) != 'undefined' )	{
				var func = new Function( onCallBack );
				func( );
			}
		}
		else
			elem.fadeTimeOut = setTimeout( "fadeElement ( '" + elem.id + "', " + nAlpha + ", " + nStep + ", " + nInterval + ", \"" + onCallBack + "\" )", nInterval );
	}

	function setElementOpacity ( something, opacity )	{
		var old = something;
		something = toObject( something );
		if( !something )
			alert( something + " " + old );

		if( opacity < 0 )
			opacity = 0;
		else if( opacity > 1 )
			opacity /= 100;

		if( document.all )
			something.style.filter = 'alpha(opacity=' + ( opacity * 100 ) + ')';
		else
			something.style.MozOpacity = opacity;
		something.style.opacity = opacity;
	}
