//------+
// Initialize globals
//------+
var stoTime = 4000; // time between image transitions

//------+
// imgTransInit(imgId) -- Initialize image transition object for img element with id=imgId
//------+
function imgTrans(imgId)
{
   this.imgId = imgId;
   this.imgList = new Array();
   this.imgElem = document.getElementById(imgId);
   this.imgCnt = 0;
   this.curImg = 0;
}

//------+
// imgTransAdd(it,imgSrc,x,y) -- add an image to the transition set
//------+
function imgTransAdd(it,imgSrc,x,y)
{
   with (it) {
      if (x == 0 || y == 0) {
	 imgList[imgCnt] = new Image();
      }
      else {
	 imgList[imgCnt] = new Image(x,y);
      }
      imgList[imgCnt].src = imgSrc;
      imgCnt++;
   }
}

//------+
// imgTransStart(it) -- Start the image transition for imgTrans object
//------+
function imgTransStart(it)
{
   var funcRef = iT_trans(it);
   setInterval(funcRef, stoTime);
}

//------+
// iT_setTime() -- Start the image transition for imgTrans object
//------+
function iT_setTime(it)
{
}

//------+
// iT_trans(it) - transitions to the next image
//------+
function iT_trans(it)
{
   return (function iT_trans_inner() {
      with (it) {
	 if (imgCnt) {
	    curImg++;
	    if (curImg >= imgCnt) {
	       curImg = 0;
	    }
	    if (imgElem.filters && imgElem.filters[0]) {
	       imgElem.filters[0].Apply();
	       imgElem.filters[0].Play();
	    }
	    imgElem.src = imgList[curImg].src;
	 }
      }
   });
}
