<!--
var delay = 10000;
var lastSlot = 1;
var baseDir = '';

//Generates a random number from 1 to x.
function rdmNum(x){
	return Math.floor(Math.random()*x) + 1
}

//main function that changes the images.
function imageSwap(){

	// Choose a slot randomly
	var rSlotNum = rdmNum(6);
	var slot = "slot" + rSlotNum;
	
		if (rSlotNum == lastSlot) {
			imageSwap();
		}else{
			//create an array of the current image sources.
			var currentImgs = new Array();
			currentImgs[0] = document.getElementById("slot1").src;
			currentImgs[1] = document.getElementById("slot2").src;
			currentImgs[2] = document.getElementById("slot3").src;
			currentImgs[3] = document.getElementById("slot4").src;
			currentImgs[4] = document.getElementById("slot5").src;
			currentImgs[5] = document.getElementById("slot6").src;
			
			// choose a new image randomly.
			var rImgNum=rdmNum(37);
			var imgSrc = baseDir + "/wp-content/themes/loyola/banner/img" + rImgNum + ".jpg";

			current = currentImgs.join();

			if (current.indexOf(imgSrc) < 0){
			
				jQuery("#"+slot).clone(true).attr("src", imgSrc).insertBefore(jQuery("#"+slot));

				jQuery("#"+slot).next().fadeOut(3000, function()
					{
						jQuery("#"+slot).next().remove();
					});
				
				lastSlot = rSlotNum;
				timer("imageSwap()", delay);
			}else{
				imageSwap();
			}	
		}
}

//set timer
function timer(func, x)
{
var t=setTimeout(func, x);
}

jQuery(document).ready(
	function()
	{
		baseDir = document.getElementById("slot1").src;
		baseIndex = baseDir.indexOf("/wp-content/");
		baseDir = baseDir.substr(0,baseIndex);
		timer('imageSwap()',delay);
	}
);
//-->