	/* Slideshow Settings: */

	var intervalTime = 7000; /* Sets speed of slideshow - changes slide every x milliseconds (1 sec = 1000 ms) */
	var transitionTime = 1000; /* Sets speed of fade in/fade out every x milliseconds (1 sec = 1000 ms) */

	/* Global variables */
	
	var imgArr = new Array();   /* Create an array for slide ids */
	var currSlideIndex = 0;		/* Current slide number (index) - starts at 0 (slide 1) */
	
	/* On page load hide all the slides, load the array, and then start slideshow */

	

	/* The following function loads all the slide ids into an array for referencing slide position during slideshow */
	
	function loadArray() {
		$j('#SlideshowContainer .Slide').each(function () {
			var slideIds = $j(this).attr('id');
			imgArr.push(slideIds);
		});
	}

	/* The following function starts the slideshow at first slide and binds events */
	
	function startSlideshow() {
		var timerId, SlideId, imgArrIndex;

		if (imgArr.length > -1) {   /* If there are slides in array */
			fadeInSlide(currSlideIndex); /* Fade in first slide */
			timerId = setInterval(changeSlide, intervalTime);  /* Change slide every x milliseconds */
			
			/* Mouse events */

			//$j('.Slide').mouseover(function () {   /* Hovering mouse over slide will pause slide changing */
				//clearInterval(timerId);
			//});

			//$j('.Slide').mouseout(function () {   /* Removing mouse from slide will start the slide changing in x milliseconds */
				//timerId = setInterval(changeSlide, intervalTime);
			//});

			
		}
	}

	/* Following function fades in a slide - callback:  image block fades in first, then caption block */
	
	function fadeInSlide(num) {
		$j('#' + imgArr[num] + ' .ImageBlock').fadeIn(transitionTime);
		$j('#' + imgArr[num] + ' .CaptionBlock').fadeIn(transitionTime);
	}

	/* Following function fades out a slide - image block first and caption block fade out at same time */
	
	function fadeOutSlide(num) {
		$j('#' + imgArr[num] + ' .ImageBlock').fadeOut(transitionTime);
		$j('#' + imgArr[num] + ' .CaptionBlock').fadeOut(transitionTime);
	}

	/* Following function changes to next slide within the interval loop (slideshow) */
	
	function changeSlide() {
		fadeOutSlide(currSlideIndex);
		currSlideIndex ++;
		 if (currSlideIndex > imgArr.length-1) {
			currSlideIndex = 0;
		} 
		fadeInSlide(currSlideIndex);
	}

	
