var ixf = { 'clock' : null, 'count' : 1 }
function crossfade()
{
	if(ixf.clock == null)
	{
		ixf.obj = arguments[0];
		ixf.src = arguments[1];
		if(typeof ixf.obj.style.opacity != 'undefined')
		{
			ixf.type = 'w3c';
		}
		else if(typeof ixf.obj.style.MozOpacity != 'undefined')
		{
			ixf.type = 'moz';
		}
		else if(typeof ixf.obj.style.KhtmlOpacity != 'undefined')
		{
			ixf.type = 'khtml';
		}
		else if(typeof ixf.obj.filters == 'object')
		{
			ixf.type = (ixf.obj.filters.length > 0 && typeof ixf.obj.filters.alpha == 'object' && typeof ixf.obj.filters.alpha.opacity == 'number') ? 'ie' : 'none';
		}
		else
		{
			ixf.type = 'none';
		}
		if(typeof arguments[3] != 'undefined' && arguments[3] != '')
		{
			ixf.obj.alt = arguments[3];
		}
		if(ixf.type != 'none')
		{
			ixf.newimg = ixf.obj.parentNode.appendChild((typeof document.createElementNS != 'undefined') ? document.createElementNS('http://www.w3.org/1999/xhtml', 'img') : document.createElement('img'));
	        ixf.newimg.style.position = 'absolute';
	        ixf.newimg.style.visibility = 'hidden';
//			ixf.newimg.className = 'idupe';
			ixf.newimg.src = ixf.src
	        ixf.newimg.style.left = ixf.obj.offsetLeft + 'px';
	        ixf.newimg.style.top = ixf.obj.offsetTop + 'px';
			ixf.length = parseInt(arguments[2], 10) * 1000;
			ixf.resolution = parseInt(arguments[2], 10) * 20;
			ixf.clock = setInterval('ixf.crossfade()', ixf.length/ixf.resolution);
		}
		else
		{
			ixf.obj.src = ixf.src;
		}
	}
};
ixf.crossfade = function()
{
	ixf.count -= (1 / ixf.resolution);
	if(ixf.count < (1 / ixf.resolution))
	{
		clearInterval(ixf.clock);
		ixf.clock = null;
		ixf.count = 1;
		ixf.obj.src = ixf.src;
	}
	switch(ixf.type)
	{
		case 'ie' :
			ixf.obj.filters.alpha.opacity = ixf.count * 100;
			ixf.newimg.filters.alpha.opacity = (1 - ixf.count) * 100;
			break;
		case 'khtml' :
			ixf.obj.style.KhtmlOpacity = ixf.count;
			ixf.newimg.style.KhtmlOpacity = (1 - ixf.count);
			break;
		case 'moz' : 
			ixf.obj.style.MozOpacity = (ixf.count == 1 ? 0.9999999 : ixf.count);
			ixf.newimg.style.MozOpacity = (1 - ixf.count);
			break;
		default : 
			ixf.obj.style.opacity = (ixf.count == 1 ? 0.9999999 : ixf.count);
			ixf.newimg.style.opacity = (1 - ixf.count);
	}
	ixf.newimg.style.visibility = 'visible';
	ixf.newimg.style.left = ixf.obj.offsetLeft + 'px';
	ixf.newimg.style.top = ixf.obj.offsetTop + 'px';
	if(ixf.count == 1)
	{
		ixf.newimg.parentNode.removeChild(ixf.newimg);
	}
};
function CreateSlideShow(imgObject, speed, duration, loop)
{
	if( !document.SlideShowArray ) document.SlideShowArray = new Array()
	if( !document.SlideShowCounter ) document.SlideShowCounter = 0;
	if( imgObject.name == "" )
	{
		imgObject.name = "slide" + document.SlideShowCounter++;
	}
	if( document.SlideShowArray[imgObject.name] == null)
	{
		document.SlideShowArray[imgObject.name] = new SlideShowObject(imgObject, CreateSlideShow.arguments)
		setTimeout('RunSlideShow(\"' + imgObject.name + '\")', ( speed > (duration*1000) ? speed - (duration*1000) : 0))
	}
	function SlideShowObject(imgObject, arg)
	{
		this.object = imgObject;
		this.speed = arg[1];
		this.duration = arg[2];
		this.Pic = new Array();
		for (i=4; i < (arg.length); i++) {
			this.Pic[i-4] = arg[i];
		}
		this.j = 0
		this.p = this.Pic.length		
		this.preLoad = new Array()
		for (i = 0; i < this.p; i++){
		   this.preLoad[i] = new Image()
		   this.preLoad[i].src = this.Pic[i]
		}
		this.loop = arg[3] * this.p;
	}
}
function RunSlideShow(id){
	var obj = document.SlideShowArray[id];
	if( obj )
	{
		if (obj.loop != 0)
		{
			if( obj.preLoad[document.SlideShowArray[id].j].complete )
			{
				if (document.all){
					obj.object.style.filter="blendTrans(duration=" + document.SlideShowArray[id].duration + ")"
					obj.object.filters.blendTrans.Apply()      
    				obj.object.src = document.SlideShowArray[id].preLoad[document.SlideShowArray[id].j].src
					obj.object.filters.blendTrans.Play()
				}else{
    				crossfade(obj.object, document.SlideShowArray[id].preLoad[document.SlideShowArray[id].j].src, document.SlideShowArray[id].duration)
				}
				obj.j = obj.j + 1;
				if (obj.j > (obj.p-1))
					obj.j=0;
				if (obj.loop > 0)
				obj.loop--;
			}			
			setTimeout('RunSlideShow(\"' + id + '\")', obj.speed)
		}
	}
}
