// You can populate bannerImages automatically by including
// the script http://hcil.cs.umd.edu/localphp/hcil/bannerimages.php
// in your html or you can populate it manually in this file
//var bannerImages=new Array();
//bannerImages[0]='/hcil/_img/splash/img-group.jpg';
//bannerImages[1]='/hcil/_img/splash/test/bannertest1.jpg';
//bannerImages[2]='/hcil/_img/splash/test/bannertest2.jpg';
//bannerImages[3]='/hcil/_img/splash/test/bannertest3.jpg';
//bannerImages[4]='/hcil/_img/splash/test/bannertest4.jpg';
//bannerImages[5]='/hcil/_img/splash/test/bannertest5.jpg';
//bannerImages[6]='/hcil/_img/splash/test/bannertest6.jpg';

var whichBannerImage=0;
var firstLoop=true;
var needStartPause=true;

function rotateBanner() {
	if (needStartPause) {
		var nextBannerImage = new Image(); 
		nextBannerImage.src=bannerImages[whichBannerImage];
		needStartPause=false;
		setTimeout(rotateBanner,4000);
	}
	else {
		rotateBannerSequence();
	}
}

function rotateBannerSequence() {
	var banner = document.getElementById('img-center');
	banner.style.backgroundImage='url('+bannerImages[whichBannerImage]+')';
	if (whichBannerImage<bannerImages.length-1) {
		whichBannerImage++;
	}
	else {
		whichBannerImage=0;
		firstLoop=false;
	}

	if (firstLoop) {
		var nextBannerImage = new Image(); 
		nextBannerImage.src=bannerImages[whichBannerImage];
	}
	setTimeout(rotateBannerSequence,4000);
}

function rotateBannerRandom() {
	var banner = document.getElementById('img-center');
	var whichBannerImage = Math.floor(Math.random()*bannerImages.length);
	banner.style.backgroundImage='url('+bannerImages[whichBannerImage]+')';
	setTimeout(rotateBannerRandom,4000);
}
