// ----------------------------------
// THE LAST ONE CANNOT END IN A COMMA
// ----------------------------------

var arrLinks = [ 
["http://www.faith.edu/images/events/Festival_fPgS.jpg",				"http://www.faith.edu/events/festivalofcarols.html"],
["http://www.faith.edu/news/Images/anniversary.jpg",					"http://www.faith.edu/news/90ann.html"],
["http://www.faith.edu/images/splash/admissions.jpg",         			"http://www.faith.edu/admissions"],
["http://www.faith.edu/images/splash/seminary.jpg",           			"http://www.faith.edu/seminary"]



];

var theInterval = 4;
var theFadeSpeed = 50;
var theWidth = 600;
var theHeight = 300;



// ----------------------------
// DO NOT EDIT BELOW THIS POINT
// ----------------------------

var objFade = '<div id="theDiv" style="width: ' + theWidth + 'px; height: ' + theHeight + 'px; display: block; border: 0px;">';
objFade += '<a href="" id="theLink"><img src="" id="theImage" style="width: ' + theWidth + 'px; height: ' + theHeight + 'px; border: 0px;"></a></div>';
document.write(objFade);

function setOpacity(obj, amount) {
  var ie = (document.all) ? true : false;
  if (ie) {obj.style.filter = 'alpha(opacity:' + amount + ')';}
  else {obj.style.opacity = amount / 100;}
}

function processFade() {
  if (currentOpacity == 0 || currentOpacity == 100) {theLink.href = arrLinks[nextIndex][1];}
  currentOpacity = currentOpacity + theIncrement;
  setOpacity(theImage, currentOpacity);
  if (currentOpacity >= 0 && currentOpacity <= 100) {setTimeout("processFade()", theFadeSpeed);}
  else {
    currentIndex++;
    if (currentIndex == arrLinks.length) {currentIndex = 0;}
    nextIndex = currentIndex + 1;
    if (nextIndex == arrLinks.length) {nextIndex = 0;}

    theIncrement = theIncrement * -1;

    if (whichImage == 'image') {theImage.src = arrLinks[nextIndex][0];}
    else {theDiv.style.background = 'url(' + arrLinks[nextIndex][0] + ')';}
    whichImage = (whichImage == 'image') ? 'div' : 'image';

    setTimeout("processFade()", theInterval);
  }
}

var theDirection = 'out';
var whichImage = 'image';
var currentIndex = 0;
var nextIndex = 1;
var currentOpacity = 100;
var theIncrement = -10;
var theDiv = document.getElementById('theDiv');
var theImage = document.getElementById('theImage');
var theLink = document.getElementById('theLink');
theInterval = theInterval * 1000;

theImage.src = arrLinks[currentIndex][0];
theLink.href = arrLinks[currentIndex][1];
theDiv.style.background = 'url(' + arrLinks[currentIndex + 1][0] + ')';

setTimeout("processFade()", theInterval);

var img_preload = new Array();
for (i = 0; i < arrLinks.length; i++) {
  img_preload[i] = new Image();
  img_preload[i].src = arrLinks[i][0];
}
