var imageURL = new Array(), imageArray = new Array(), captionArray = new Array(), e;
  var currentImageIndex = 0, nextImageIndex, imageOpacity, imageMaxOpacity = 1, direction = "none";

  //----YOU CAN EDIT THESE PARAMETERS//
  var fadeSpeed = 0.07; //0 < fadeSpeed < 1
  var transitionInterval = 0.5; //in seconds
  var randomizeImages = false; //true or false
  var displayButtons = true; //true or false
  var displayCaptions = false; //true or false
  var fadeColour = "#FFFFFF"; //hexidecimal colour value
  var imageBorder = "1px #000000 solid"; //width | colour | style
  //---------------------------------//
  /*@cc_on fadeSpeed = fadeSpeed * 100; imageMaxOpacity = 100; @*/

  //----IMAGES OF ANY DIMENSIONS MAY BE INCLUDED//
  //----INFINITE AMOUNT OF IMAGES PERMITTED//
  //----IMAGES MAY BE NAMED ANYTHING, SCRIPT HAS NO RELIANCE ON NAME//
  imageURL[0] = "home/ferns2.jpg";
  imageURL[1] = "home/main_photo.jpg";
  imageURL[2] = "home/entrance.jpg";
  imageURL[3] = "home/kitchen_lounge_sarah_jayne.jpg";
  imageURL[4] = "home/lounge_bed_sarah_ jayne.jpg";
  imageURL[5] = "home/lounge_kitchen_sarah_jayne.jpg";
  imageURL[6] = "home/spa_sarah_sayne.jpg";

  //----ENTER CAPTION TO DISPLAY FOR EACH IMAGE//
  //----IN SAME ORDER AS IMAGE URL'S HAVE BEEN ENTERED//
  //----HENCE, THERE SHOULD BE EQUAL NUMBER OF CAPTIONS:IMAGES
  captionArray[0] = "Caption 1";
  captionArray[1] = "Caption 2";
  captionArray[2] = "Caption 3";
  captionArray[3] = "Caption 4";
  captionArray[4] = "Caption 2";
  captionArray[5] = "Caption 3";
  captionArray[6] = "Caption 4";
  window.onload = init;

  //initialisation
  function init() {
    //assign each image to imageArray whose URL specified above
    for (var i = 0; i < imageURL.length; i++) {
      imageArray[i] = new Image();
      imageArray[i].src = imageURL[i];
    }
    e = document.getElementById("transitionImage");
    e.style.border = imageBorder;
    document.getElementById("imageCell").style.backgroundColor = fadeColour;
    //display first image
    if (randomizeImages == true)
      randomize();
    else
      incrementForward();
    //hide buttons if displayButtons == false
    if (displayButtons == false) {
      document.getElementById("buttonBack").style.display = "none";
      document.getElementById("buttonForward").style.display = "none";
    }
    try {imageOpacity = e.style;} catch(err) {}
    try {imageOpacity = e.filters.alpha;} catch(err) {}
    transitionDelay();
  }

  //performs interval/delay between transitions
  function transitionDelay() {
    t = setTimeout("fadeOut()", transitionInterval * 10000);
  }

  //fades out image to 0% opacity
  function fadeOut() {
    if (imageOpacity.opacity - fadeSpeed <= 0) {
      imageOpacity.opacity = 0;
      if (randomizeImages == true) {randomize();}
      else {(direction == "back") ? incrementBack() : incrementForward();}
      fadeIn();
    } else {
      imageOpacity.opacity = imageOpacity.opacity - fadeSpeed;
      t = setTimeout("fadeOut()", 20);
    }
  }

  //randomly select the next image to display in transition
  function randomize() {
    do {nextImageIndex = Math.floor(Math.random() * imageArray.length);}
    while (nextImageIndex == currentImageIndex)
    e.src = imageArray[nextImageIndex].src;
    currentImageIndex = nextImageIndex;
    displayCaption();
  }

  //display next image in transition
  function incrementForward() {
    if (currentImageIndex + 1 == imageArray.length) {currentImageIndex = 0;}
    else {currentImageIndex++;}
    e.src = imageArray[currentImageIndex].src;
    displayCaption();
  }

  //display previous image in transition
  function incrementBack() {
    if (currentImageIndex - 1 == -1) {currentImageIndex = imageArray.length - 1;}
    else {currentImageIndex--;}
    direction = "none";
    e.src = imageArray[currentImageIndex].src;
    displayCaption();
  }

  //display caption for current image
  function displayCaption() {
    if (displayCaptions == true && captionArray[currentImageIndex])
      document.getElementById("caption").innerHTML = captionArray[currentImageIndex];
    else
      document.getElementById("caption").innerHTML = "";
  }

  //fades in image to 100% opacity
  function fadeIn() {
    if (imageOpacity.opacity + fadeSpeed >= imageMaxOpacity) {
      imageOpacity.opacity = imageMaxOpacity;
      transitionDelay();
    } else {
      var temp;
      imageOpacity.opacity = (imageOpacity.opacity * 1) + fadeSpeed;
      t = setTimeout("fadeIn()", 20);
    }
  }