/***
 * Michael Woods
 * NJSPB, 2007
 ***/

var splashIndex = 0;
/**
 *
 */
function SplashImage(filename, desc)
{
	this.filename = filename;
	this.desc = desc;
	this.img = new Image();
	this.img.src = filename;
	this.img.alt = desc;
}
/**
 *
 */
NJSPBSplashImages = [
	new SplashImage("img/splash/parole_1.jpg", "Parole: Community Programs Automotive Technical Training"),
	new SplashImage("img/splash/parole_2.jpg", "Parole: Parolee Counseling"),
	new SplashImage("img/splash/parole_3.jpg", "Parole: Hearings and Victim Services"),
	//new SplashImage("img/splash/parole_4.jpg", "Parole: Community Programs Computer Training"),
	new SplashImage("img/splash/parole_5.jpg", "Parole: Fugitive Apprehension and Gang Intervention"),
	new SplashImage("img/splash/parole_6.jpg", "Parole: Parole Officer Training"),
	new SplashImage("img/splash/parole_7.jpg", "Parole: Sex Offender Supervision"),
	//new SplashImage("img/splash/parole_8.jpg", "Parole: Parole Counselor Training"),
	new SplashImage("img/splash/parole_9.jpg", "Parole: Community Supervision")
]
/**
 *
 */
function swapSplashImg(imgElementId, imgOverlayId)
{
	//
	var si = $('#' + imgElementId);
	var oi = $('#' + imgOverlayId);
	//
	if (splashIndex < 0 || splashIndex >= NJSPBSplashImages.length - 1) {
		splashIndex = 0;
	}else {
		splashIndex++;	}
	//
	if (imgElementId && si) {
		if (NJSPBSplashImages[splashIndex]) {
			if (NJSPBSplashImages[splashIndex].img) {
				si.attr('src', NJSPBSplashImages[splashIndex].img.src);
			}
			if (NJSPBSplashImages[splashIndex].desc) {
				si.attr('alt', NJSPBSplashImages[splashIndex].desc);
			}
		} 
	}
	//
	if (imgOverlayId && oi) {
		oi.fadeTo(100, 1.0);
		oi.text(NJSPBSplashImages[splashIndex].desc);
		oi.fadeTo(500, 0.85);
	}
}
/**
 *
 */
function timedImgSwap()
{
	swapSplashImg('splash_img', 'splash_overlay');
	setTimeout("timedImgSwap()", 2500);
}
/**
 *
 */
$(document).ready(function() {
	swapSplashImg('splash_img');
	timedImgSwap();
});

