var isf = { 'clock' : null, 'fade' : true, 'count' : 1 }

function swapfade()
{
	if(isf.clock == null)
	{
		isf.obj = arguments[0];
		isf.src = arguments[1];
		if(typeof isf.obj.style.opacity != 'undefined')
		{
			isf.type = 'w3c';
		}
		else if(typeof isf.obj.style.MozOpacity != 'undefined')
		{
			isf.type = 'moz';
		}
		else if(typeof isf.obj.style.KhtmlOpacity != 'undefined')
		{
			isf.type = 'khtml';
		}
		else if(typeof isf.obj.filters == 'object')
		{
			isf.type = (isf.obj.filters.length > 0 && typeof isf.obj.filters.alpha == 'object' && typeof isf.obj.filters.alpha.opacity == 'number') ? 'ie' : 'none';
		}
		else
		{
			isf.type = 'none';
		}
		if(typeof arguments[3] != 'undefined' && arguments[3] != '')
		{
			isf.obj.alt = arguments[3];
		}
		if(isf.type != 'none')
		{
			isf.length = parseInt(arguments[2], 10) * 100;
			isf.resolution = parseInt(arguments[2], 10) * 10;
			isf.clock = setInterval('isf.swapfade()', isf.length/isf.resolution);
		}
		else
		{
			isf.obj.src = isf.src;
		}
		
	}
};

isf.swapfade = function()
{
	isf.count = (isf.fade) ? isf.count * 0.7 : (isf.count * (1/0.7)); 
	if(isf.count < (1 / isf.resolution))
	{
		clearInterval(isf.clock);
		isf.clock = null;
		isf.obj.src = isf.src;
		isf.fade = false;
		isf.clock = setInterval('isf.swapfade()', isf.length/isf.resolution);
	}
	
	if(isf.count > (1 - (1 / isf.resolution)))
	{
		clearInterval(isf.clock);
		isf.clock = null;
		isf.fade = true;
		isf.count = 1;
	}
	
	switch(isf.type)
	{
		case 'ie' :
			isf.obj.filters.alpha.opacity = isf.count * 100;
			break;
		case 'khtml' :
			isf.obj.style.KhtmlOpacity = isf.count;
			break;
		case 'moz' : 
			isf.obj.style.MozOpacity = (isf.count == 1 ? 0.9999999 : isf.count);
			break;
		default : 
			isf.obj.style.opacity = (isf.count == 1 ? 0.9999999 : isf.count);
	}
};



