// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed and fade speed (milliseconds)
var slideShowSpeed = 3500
var fadeSpeed = 1500;

// 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] = 'images/animation/image-1.jpg';
Pic[1] = 'images/animation/image-2.jpg';
Pic[2] = 'images/animation/image-3.jpg';
Pic[3] = 'images/animation/image-4.jpg';
Pic[4] = 'images/animation/image-5.jpg';
Pic[5] = 'images/animation/image-6.jpg';
Pic[6] = 'images/animation/image-7.jpg';
Pic[7] = 'images/animation/image-8.jpg';
Pic[8] = 'images/animation/image-9.jpg';
Pic[9] = 'images/animation/image-1.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(); });
}


