// ///////////////////////////////////////////////////////////////////////////////
// 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/k-rith/";

// ///////////////////////////////////////////////////////////////////////////////
// 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("k-rith_banner0.jpg","null", "null");
//populate("k-rith_banner1.jpg","null", "null");
//populate("k-rith_banner2.jpg","null", "null");
//populate("k-rith_banner3.jpg","null", "null");
//populate("k-rith_banner4.jpg","null", "null");
//populate("k-rith_banner5.jpg","null", "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];
}

function fImgMapProc(pos) {
	var loc = features[fIdx][pos];
	document.location = loc;
}
