<!--

/*
how to use this script:
1) call AddPicRotator() with first argument equal to the id of the img. 
   Supply an arbitrary number of additional arguments, absolute paths, from the web root, of each image in the rotation
2) call startTimer()

* startTimer() need only be called once. Each call to AddPicRotator adds a new rotator to a list, and all rotators on a page rotate together
* Edit the timerEvent() function to change the rotation speed. 
  The second argument in the call to setTimeout() is the rotation frequency in milliseconds

*/
var picRotators=new Array()
var timerID = null
var timerRunning = false

function picRotator (containerid)
{
	this.index = 0
	this.ID=containerid
	this.pics=new Array()
}

function AddPicRotator(id)
{
	var index = picRotators.length
	
	picRotators[index] = new picRotator(id)
	var i,j
	for(i=1, j=0; i<AddPicRotator.arguments.length; i++, j++)
	{
		picRotators[index].pics[j] = AddPicRotator.arguments[i]
	}


}

function RotatePic(obj)
{
	if(obj.index >= obj.pics.length)
		obj.index = 0
	document.getElementById(obj.ID).src=obj.pics[obj.index]
	obj.index = obj.index + 1
}

function RotateAllPics()
{
	var i
	for(i=0; i<picRotators.length; i++)
		RotatePic(picRotators[i])
}

function stopTimer(){
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function startTimer(){
    stopTimer()
    timerEvent()
}

function timerEvent(){
	
	RotateAllPics()
    timerID = setTimeout("timerEvent()",5000)
    timerRunning = true
}
-->