/*

	File name:	spotlight_rotation.js
	File author:	Geoffrey Pagel
	
	Description:	This script rotates the images and captions for "In the Spotlight"
			on the department home page.
					
			The photos and captions are controlled within the CMS.  When the document
			loads, a PHP script fetches the image names, captions, and links and passes
			them to this script, which presents the data to the user in pretty form.
					
*/

if (document.images) {
	g = new Image;
	s = new Image;
	g.src = "images/spotlight/play.gif";
	s.src = "images/spotlight/pause.gif";
}

var prefix = "images/features/";
var thisSpot = 0;
var t;

function rotate() {
	imgCount = spotImages.length - 1;

	if (document.images) {
		if (thisSpot > imgCount) {
			thisSpot = 0;
		}
		document.Spotlight.src = prefix + spotFileName[thisSpot];
		//document.getElementById("SpotlightCaption").innerHTML = spotCaption[thisSpot];
		
		t = setTimeout("rotate()", 8000);
		thisSpot++;
	}
}

function redirectURL() {
	document.location.href = spotURL[thisSpot];
}

function chooseSpot(direction) {
	if (document.images) {
		thisSpot += direction;
		if (thisSpot > imgCount) {
			thisSpot = 0;
		} else if (thisSpot < 0) {
			thisSpot = imgCount;
		}
		document.Spotlight.src = prefix + spotFileName[thisSpot];
		//document.getElementById("SpotlightCaption").innerHTML = spotCaption[thisSpot];		
	}
}

function pauseSpot() {
	if (document.images) {
		if (document.rotcontrol.src == s.src) {
			document.rotcontrol.src = g.src;
			window.clearTimeout(t);
		} else {
			document.rotcontrol.src = s.src;
			t = setTimeout("rotate()", 8000);
		}
	}
}