// JavaScript Document
//Preload images
var image1 = new Image();
image1.src = "images/mastheadSlide/01.jpg";
var image2 = new Image();
image2.src = "images/mastheadSlide/02.jpg";
var image3 = new Image();
image3.src = "images/mastheadSlide/03.jpg";
var image4 = new Image();
image4.src = "images/mastheadSlide/04.jpg";
var image5 = new Image();
image5.src = "images/mastheadSlide/05.jpg";
var image6 = new Image();
image6.src = "images/mastheadSlide/06.jpg";

//Global variables
var numslides=0;
var currentslide=0,oldslide=4;
var x = 0;
var slides = new Array();
function MakeSlideShow() {
	// find all images with the class "slide"
	imgs=document.getElementsByTagName("img");
	for (i=0; i<imgs.length; i++) {
		if (imgs[i].className != "slide") continue;
		slides[numslides]=imgs[i];
		// stack images with first slide on top
		if (numslides==0) {
			imgs[i].style.zIndex=10;
		} else {
			imgs[i].style.zIndex=0;
		}
		//imgs[i].onclick=NextSlide;      This will change the image when the image is clicked
			numslides++;
		} // end for loop
		
		var Interval = window.setInterval('NextSlide()', 5000);
	} // end MakeSlideShow()
	function NextSlide() {
		// Set current slide to be under the new top slide
		slides[currentslide].style.zIndex=9;
		// Move older slide to the bottom of the stack
		slides[oldslide].style.zIndex=0;
		oldslide = currentslide;
		currentslide++;
		if (currentslide >=numslides) currentslide = 0;
		// start at the right edges
		slides[currentslide].style.left=900;
		x=900;
		//Move the new slide to the top
		slides[currentslide].style.zIndex=10;
		
		//uncoment below to slide images on transitions
		//AnimateSlide();
		//comment out below to slide images on transitions
		slides[currentslide].style.left=0;
	}
	function AnimateSlide() {
		// Lower moves slower, higher moves faster
		x = x - 25;
		slides[currentslide].style.left=x;
		// previous image moves off the left edge
		// (comment the next line for a different effect)
		//slides[oldslide].style.left=x-400;
		// repeat until slide is at zero posotion
		if (x > 0) window.setTimeout("AnimateSlide();",10);
	}
	// create the slideshow when the page loads
	window.onload=MakeSlideShow;