//rotate an image through a list of images
var cyclelist = new Array(
	"success.jpg",
	"justice.jpg",
	"passion.jpg",
	"peace.jpg",
	"discovery.jpg",
	"tradition2.jpg",
	"wonder.jpg",
	"honor.jpg",
	"compassion.jpg",
	"faith.jpg",
	"ideas.jpg"
);
var cycledir = false;
var cyclecount = 0;
//duration in seconds
var cycleduration = 5;
var cyclestarted = false;

function cycleImage() {
	imageInfo = cyclelist[cyclecount];

	//is this a string (which means we only change the image source)
	//or an array (which means we change both the image source and the href)
	if (typeof imageInfo == "string") {
		imageSRC = imageInfo;
	} else {
		imageSRC = imageInfo[0];
		imagelink = imageInfo[1];
		cyclelink = cycletarget.parentNode;
		cyclelink.href = imagelink;
	} 

	if (cycledir) {
		imageSRC = cycledir + imageSRC;
	}
	cycletarget.src=imageSRC;

	cyclecount++;
	if (cyclecount == cyclelist.length) {
		cyclecount = 0;
	}
	setTimeout("cycleImage()", cycleduration*1000);
}

function cycleMe(image, duration, imagelist, imagedir) {
	if (!cyclestarted) {
		cyclestarted = true;

		cycletarget = image;
		if (imagelist) {
			cyclelist = imagelist;
		}
		if (imagedir) {
			cycledir = imagedir;
		}
		if (duration) {
			cycleduration = duration;
		}
		cycleImage();
	}
}
