
function RunSlideShow(id){
	if( document.SlideShowArray[id] )
	{
		if( document.SlideShowArray[id].preLoad[document.SlideShowArray[id].j].complete )
		{
			if (document.all){
				document.SlideShowArray[id].object.style.filter="blendTrans(duration=" + document.SlideShowArray[id].crossFadeDuration + ")"
				document.SlideShowArray[id].object.filters.blendTrans.Apply()      
			}
			document.SlideShowArray[id].object.src = document.SlideShowArray[id].preLoad[document.SlideShowArray[id].j].src
			if (document.all){
				document.SlideShowArray[id].object.filters.blendTrans.Play()
			}
			document.SlideShowArray[id].j = document.SlideShowArray[id].j + 1
			if (document.SlideShowArray[id].j > (document.SlideShowArray[id].p-1)) document.SlideShowArray[id].j=0
		}
		setTimeout('RunSlideShow(\"' + id + '\")', document.SlideShowArray[id].slideShowSpeed)
	}
}

function SlideShowObject(imgObject, arg)
{
	this.object = imgObject
	this.slideShowSpeed = arg[1]
	this.crossFadeDuration = arg[2]
	this.Pic = new Array()
	
	for (i=3; i < (arg.length); i++) {
		this.Pic[i-3] = 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]
	}
}

// Params: imgObject, slideShowSpeed, crossFadeDuration, slideShowImages
// eg: <img src="../../includes/slideshow1.jpg" onload="CreateSlideShow(this,4000,2,'slideshow2.jpg','slideshow3.jpg','slideshow1.jpg')">
function CreateSlideShow(imgObject, slideShowSpeed, crossFadeDuration)
{
	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 + '\")', ( slideShowSpeed > (crossFadeDuration*1000) ? slideShowSpeed - (crossFadeDuration*1000) : 0))
	}
}
