var numShowImages = 10;
var numImages = 27;
var numInterval = 5000;
var numImageHold = 3;
var numImageFade = 1;

var imgItems = new Array();

for (i=1; i<=numShowImages; i++) {
  var tmpNum = RandomNumber(numImages);
  var tmpFile = CreateFileName(tmpNum);
  imgItems[i] = new GetImage(tmpFile);
}

function RandomNumber(NumRange) {
  return Math.floor(Math.random() * NumRange) + 1;
}

function GetImage(filename) {
  this.image_item = new Image();
  this.image_item.src = filename;
}

function GetImageLocation(imageObj) {
  return(imageObj.image_item.src);
}

function CreateFileName(numFile) {
  var tmpNum = numFile.toString();
  var tmpFile;
  if (tmpNum.length == 1) tmpFile = 'images/slides/slide00' + tmpNum + '.jpg'
  if (tmpNum.length == 2) tmpFile = 'images/slides/slide0' + tmpNum + '.jpg'
  if (tmpNum.length == 3) tmpFile = 'images/slides/slide' + tmpNum + '.jpg'
  return tmpFile;
}

function ClickOnImage(imgCell) {
  var tmpFile = document[imgCell].src;
  tmpFile = tmpFile.substr(tmpFile.indexOf('slides') + 7, 9) + 'html';
  location.href = tmpFile;
}

function StartRotation() {
  var tmpNum = RandomNumber(numShowImages);
  var tmpImage = GetImageLocation(imgItems[tmpNum]);
  return (tmpImage);
}

function rotateImage(imgCell) {
  if (document.all) {
    document[imgCell].style.filter = 'blendTrans(duration=numImageHold)';
    document[imgCell].style.filter = 'blendTrans(duration=numImageFade)';
    document[imgCell].filters.blendTrans.Apply();
  }
  document[imgCell].src = StartRotation();
  if (document.all) {
    document[imgCell].filters.blendTrans.Play();
  }
  var tmpRecall = 'rotateImage("' + imgCell + '")';
  timerID = setTimeout(tmpRecall, numInterval);
}

