/*

	File name:	spotlight_rotation.js
	File author:	Geoffrey Pagel
	
	Description:	This script rotates the images and captions for "In the Feature"
			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/features/play.gif";
	s.src = "images/features/pause.gif";
}

var prefix = "images/features/";
//var prefix = "";
//var thisFeature = 0;

var t;

function rotate() {
	imgCount = featureImages.length - 1;

	if (document.images) {


		thisFeature++;
		if (thisFeature > imgCount) {
			thisFeature = 0;
		}
		
		document.Feature.src = prefix + featureFileName[thisFeature];
                
		t = setTimeout("rotate()", 5000);
	}
}

function redirectURL() {
	document.location.href = featureURL[thisFeature];
}

function chooseSpot(direction) {
	if (document.images) {
		thisFeature += direction;
		if (thisFeature > imgCount) {
			thisFeature = 0;
		} else if (thisFeature < 0) {
			thisFeature = imgCount;
		}
		document.Feature.src = prefix + featureFileName[thisFeature];
	}
}

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()", 10000);
		}
	}
}