/* ####################### varibles definition ####################### */
currentIndx = 0;
automatic = 1;
delayTime = 3500;

/* ####################### begins list of images to be used ####################### */
/* ###### defined in invocate page ######
MyImages = new Array();
MyImages[0]='image1.gif';
MyImages[1]='image2.gif';
MyImages[2]='image3.gif';
MyImages[3]='image4.gif';
*/

/* ####################### now we preload the images ####################### */
imagesPreloaded = new Array(MyImages.length)
for (var i = 0; i < MyImages.length ; i++) 
{
  imagesPreloaded[i] = new Image()
  imagesPreloaded[i].src = MyImages[i]
}

/* ####################### we create the functions to go forward and go back ####################### */
function Next(){
	if (automatic == 1) {
    automatic = 0;
    currentIndx = currentIndx-1;
  }
  if (currentIndx < imagesPreloaded.length - 1){
    currentIndx = currentIndx + 1;
    document.theImage.filters.blendTrans.apply();
    document.theImage.src = imagesPreloaded[currentIndx].src
    document.theImage.filters.blendTrans.play();
  } else {
    currentIndx = 0
    document.theImage.filters.blendTrans.apply();
    document.theImage.src = imagesPreloaded[currentIndx].src
    document.theImage.filters.blendTrans.play();
  }
  document.frmImg.imgCount.value = (currentIndx + 1) + ' / ' + MyImages.length;
}

function Back(){
	if (automatic == 1) {
    automatic = 0;
    currentIndx = currentIndx - 1;
  }
  if (currentIndx > 0){
    currentIndx = currentIndx - 1;
    document.theImage.filters.blendTrans.apply();
    document.theImage.src = imagesPreloaded[currentIndx].src
    document.theImage.filters.blendTrans.play();
  } else {
    currentIndx = imagesPreloaded.length - 1
    document.theImage.filters.blendTrans.apply();
    document.theImage.src = imagesPreloaded[currentIndx].src
    document.theImage.filters.blendTrans.play();
  }
  document.frmImg.imgCount.value = (currentIndx + 1) + ' / ' + MyImages.length;
}

function automaticly() {
	if (automatic == 1) {
    if (currentIndx < imagesPreloaded.length){
      currentIndx = currentIndx
    } else {
      currentIndx = 0
    }	
    document.theImage.filters.blendTrans.apply();
    document.theImage.src = imagesPreloaded[currentIndx].src
    document.theImage.filters.blendTrans.play();
    currentIndx = currentIndx + 1;
    document.frmImg.imgCount.value = currentIndx + ' / ' + MyImages.length;
    var delay = setTimeout("automaticly()",delayTime)
	}
}
/* ####################### end of script ####################### */

