// ///////////////////////////////////////////////////////////////////////////////
// Image Rotator
//
// by M Green (c) 2005
// v1.1
// ///////////////////////////////////////////////////////////////////////////////

// dimension control variables (do not change these)
var fIdx = -1;
features = new Array();

// image rotator speed (milli-seconds)
var fDelay = 6000;

// root folder for feature images
var fImgRoot = "/images/features/";

// ///////////////////////////////////////////////////////////////////////////////
// Populate the features array.
// ///////////////////////////////////////////////////////////////////////////////
// USAGE:
// 		populate("[image file]", "[link location]" , "[download location]");
//
// If download location is empty or "null" it be set the same as the link location.
// All links should be complete relative OR absolute paths.
// Image file and link location cannot be null. One feature per line.
//
populate("keller_feature.jpg","/news/keller20100704.html", "null");
populate("may2010_feature3.jpg","/bulletin/may2010/features/view.html", "null");
populate("univprof20100520_feature.jpg","/news/univprof20100520.html", "null");
//populate("hannon20100506a_feature.jpg","/news/hannon20100506.html", "null");
populate("may2010_feature4.jpg","/bulletin/may2010/chronicle/action.html", "null");
//populate("rafii_feature.jpg","/news/rafii20100425.html", "null");
//populate("dod_feature_egnor.jpg","/janelia/events.html", "null");
//populate("gilliam_feature.jpg","/news/gilliam20100309.html", "null");
//populate("vielle-calzada_banner.jpg","/news/viellecalzada20100307.html", "null");
//populate("feb2010_feature3.jpg","/bulletin/feb2010/centrifuge/kiddie.html", "null");
//populate("abrahamharrison_banner.jpg","/news/abrahamharrison20100307.html", "null");
//populate("feb2010_feature1.jpg","/bulletin/feb2010/", "null");
//populate("rafii01172010_feature.jpg","/news/rafii20100117.html", "null");
//populate("AR_homepage_banner.jpg","/annualreport2009/", "null");
//populate("lizards2_feature.jpg","/bulletin/nov2009/centrifuge/lizards.html", "null");
//populate("future_bulletin_feature.jpg","/bulletin/nov2009/centrifuge/future.html", "null");







// functions
function populate(imgRef, linkRef, dnlRef) {
	if (imgRef!="" && linkRef!="") {
		if (dnlRef == "" || dnlRef == "null") {
			dnlRef = linkRef
		}
		features[features.length] = new Array(imgRef, linkRef, dnlRef);
	}
}

function rotator(targetImg) {
	showNext(targetImg);
	fLoop = window.setTimeout('rotator(\''+targetImg+'\')', fDelay);
}

function manualStep(targetImg) {
	window.clearTimeout(fLoop);
	rotator(targetImg);
}

function showNext(targetImg) {
	fIdx++;
	if (fIdx >= features.length) {
		fIdx = 0;
	}
	//alert(fIdx);
	document.images[targetImg].src = fImgRoot + features[fIdx][0];
//use this line for rotating banners
	document.images["fHdr"].src = fImgRoot + "featureHdr" + fIdx + ".gif";
//use this line for static banner
	//document.images["fHdr"].src = fImgRoot + "featureHdr0_static.gif";
}

function fImgMapProc(pos) {
	var loc = features[fIdx][pos];
	document.location = loc;
}
