// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed and fade speed (milliseconds)
var slideShowSpeed = 4000
var fadeSpeed = 2000;

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below
// define random images and owners for display

Pic[0] = 'animations/images/animation-image-17.jpg';
Pic[1] = 'animations/images/animation-image-2.jpg';
Pic[2] = 'animations/images/animation-image-3.jpg';
Pic[3] = 'animations/images/animation-image-16.jpg';
Pic[4] = 'animations/images/animation-image-18.jpg';
Pic[5] = 'animations/images/animation-image-5.jpg';
Pic[6] = 'animations/images/animation-image-26.jpg';
Pic[7] = 'animations/images/animation-image-7.jpg';
Pic[8] = 'animations/images/animation-image-8.jpg';
Pic[9] = 'animations/images/animation-image-9.jpg';
Pic[10] = 'animations/images/animation-image-10.jpg';
Pic[11] = 'animations/images/animation-image-11.jpg';
Pic[12] = 'animations/images/animation-image-12.jpg';
Pic[13] = 'animations/images/animation-image-13.jpg';
Pic[14] = 'animations/images/animation-image-14.jpg';
Pic[15] = 'animations/images/animation-image-19.jpg';
Pic[16] = 'animations/images/animation-image-20.jpg';
Pic[17] = 'animations/images/animation-image-21.jpg';
Pic[18] = 'animations/images/animation-image-22.jpg';
Pic[19] = 'animations/images/animation-image-24.jpg';
Pic[20] = 'animations/images/animation-image-25.jpg';
Pic[21] = 'animations/images/animation-image-27.jpg'
Pic[22] = 'animations/images/animation-image-2.jpg';




// =======================================
// do not edit anything below this line
// =======================================

// Image cache to reduce network usage
var FadeCache = new Array();

var fadeIndex = 0;
var fadeDiv = null;

function initSlideShow() {
	fadeDiv = $(".fade").clone();
	fadeDiv.removeClass("fade");

	$(".fade").append(fadeDiv);
	
	rotateImages();
}

function rotateImages() {
	if (++fadeIndex == Pic.length) fadeIndex = 0;
	
	if (FadeCache[fadeIndex] == null) {
		FadeCache[fadeIndex] = new Image();
		$(FadeCache[fadeIndex]).attr("src", Pic[fadeIndex]).load(initFade());
		
	} else {
		initFade();
	}
}

function initFade() {
	if (fadeIndex % 2 > 0)
		$("img", fadeDiv).attr("src", FadeCache[fadeIndex].src);
	else
		$("img:eq(0)", ".fade").attr("src", FadeCache[fadeIndex].src);
	
	setTimeout("doFade()", slideShowSpeed);
}

function doFade(direction) {
	if (fadeIndex % 2 > 0)
		fadeDiv.fadeIn(fadeSpeed, function() { rotateImages(); });
	else
		fadeDiv.fadeOut(fadeSpeed, function() { rotateImages(); });
}


