///////////////////////////////////////////////////////////////////////////////////////////////////
//	DLib Object Fader JavaScript routines - copyright davidviner.com 2009
//
//	05.10.2009	5.6.1	DJV		Fixed problem that was causing errors in IE. Removed older -moz and
//								-khtml opacity fades. Added enableIE().
//
///////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////

DLibFader = function ()
{
	var fList = [];
	var ieOn = false;

	var _public =
	{
		doFade : function (o)
		{
			clearTimeout (fList[o].t);
			fList [o].opac = (fList [o].dir == 0 ? fList [o].opac - 2 : fList [o].opac + 2);
			fList [o].el.style.opacity = (fList [o].opac / 100);
			if (ieOn) fList [o].el.style.filter = "alpha(opacity=" + fList [o].opac + ")";

			if ((fList [o].dir == 0 && fList [o].opac <= 0) ||
				(fList [o].dir == 1 && fList [o].opac >= 100))
			{
				// Finished

				if (fList [o].next != "") eval (fList [o].next);
			}
			else
			{
				fList [o].t = setTimeout ("DLibFader.doFade('" + o + "')", fList [o].speed);
			}
		},

		// dir: 0 = fade, 1 = unfade

		fadeObject : function (o, dir, tm, next)
		{
			fList [o] = new Object;
			fList [o].el = document.getElementById (o);
			fList [o].speed = tm * 1000 / 50;
			fList [o].dir = dir;
			fList [o].opac = (dir == 0 ? 100 : 0);
			fList [o].next = next;
			fList [o].t = setTimeout ("DLibFader.doFade('" + o + "')", fList [o].speed);
		},

		enableIE : function (en)
		{
			ieOn = en;
		}
	};

	return _public;
} ();

///////////////////////////////////////////////////////////////////////////////////////////////////

