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

var arrLinks = [
  	  ["images/banners/counselorpromo.jpg", "http://www.youtube.com/watch?v=8R4wfuW8Auw"],
	  ["images/banners/seniorhighvid.jpg", "http://www.youtube.com/watch?v=8JtPoygS8TU"]
  
  
];

var theInterval = 6;
var theFadeSpeed = 50;
var theWidth = 940;
var theHeight = 319;



// ----------------------------
// 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) {


 }
  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];
}