﻿function slide1() {	
	
	var myImages = ['slide_pictures/pic1.jpg','slide_pictures/pic2.jpg','slide_pictures/pic3.jpg','slide_pictures/pic4.jpg','slide_pictures/pic5.jpg','slide_pictures/pic6.jpg','slide_pictures/pic7.jpg','slide_pictures/pic8.jpg','slide_pictures/pic9.jpg','slide_pictures/pic10.jpg'];
	
	// how many times should the photo change per page load
	var maxChanges = myImages.length * 30;
	
	// shuffle images so each time page loads, the photos show in different order
	var do_shuffle = true;
	
	// use simple randomness instead of shuffling (tends to repeat images too often)
	var do_randomly = false;
	
	// number of seconds between photo changes
	var seconds_between_photos = 10;
	
	// name of DIV to load photos into
	var div_name = "slideshow1";
	
	var changes = 0;
	var timer;
	var thisImg = myImages.length - 1;
	
	shuffle = function(o){ 
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	};
	
	if (do_shuffle) {
		myImages = shuffle(myImages);	
	}
	
	function nextImage () {
		
		var low = 0;
		var high = myImages.length - 1;
		var rand_no = Math.floor((high-(low - 1))*Math.random()) + low;
		
		thisImg++;
		changes++;
		if (thisImg==myImages.length) {
			thisImg = 0;
		}
		if (changes==maxChanges) {
			clearInterval(timer);
		}
		if (do_randomly) {
			thisImg = rand_no;
			return myImages[rand_no];
		} else {
			return myImages[thisImg];
		}
	}
	
	function changeImage () {
		
		var t = myImages[thisImg];
		var n = nextImage();
		
		if (t != n) {
			$("#"+div_name).addClass("loading");
			showImage(n);
		} else { 
			changeImage();
		}
	}
	
	function showImage(src)
	{
		$("#"+div_name+" img").fadeOut(500);
		var largeImage = new Image();
		$(largeImage).load(function()
							{
								$(this).hide();
								$("#"+div_name).append(this).removeClass("loading");
												 
								$(this).fadeIn(1100);              
							});    
		$(largeImage).attr("src", src);                                                                               
	}
	
	function checkForLoaded () {
		if (document.getElementById(div_name) != null) {
			//alert("loaded");
			clearInterval(timer);
			changeImage();
			timer = setInterval(changeImage, (seconds_between_photos * 1000));
		}
	}
	
	timer = setInterval(checkForLoaded, 500); 

}

function slide2() {	
	
	var myImages = ['slide_pictures/pic11.jpg','slide_pictures/pic12.jpg','slide_pictures/pic13.jpg','slide_pictures/pic14.jpg','slide_pictures/pic15.jpg','slide_pictures/pic16.jpg','slide_pictures/pic17.jpg','slide_pictures/pic18.jpg','slide_pictures/pic19.jpg','slide_pictures/pic20.jpg'];
	
	// how many times should the photo change per page load
	var maxChanges = myImages.length * 30;
	
	// shuffle images so each time page loads, the photos show in different order
	var do_shuffle = true;
	
	// use simple randomness instead of shuffling (tends to repeat images too often)
	var do_randomly = false;
	
	// number of seconds between photo changes
	var seconds_between_photos = 7;
	
	// name of DIV to load photos into
	var div_name = "slideshow2";
	
	var changes = 0;
	var timer;
	var thisImg = myImages.length - 1;
	
	shuffle = function(o){ 
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	};
	
	if (do_shuffle) {
		myImages = shuffle(myImages);	
	}
	
	function nextImage () {
		
		var low = 0;
		var high = myImages.length - 1;
		var rand_no = Math.floor((high-(low - 1))*Math.random()) + low;
		
		thisImg++;
		changes++;
		if (thisImg==myImages.length) {
			thisImg = 0;
		}
		if (changes==maxChanges) {
			clearInterval(timer);
		}
		if (do_randomly) {
			thisImg = rand_no;
			return myImages[rand_no];
		} else {
			return myImages[thisImg];
		}
	}
	
	function changeImage () {
		
		var t = myImages[thisImg];
		var n = nextImage();
		
		if (t != n) {
			$("#"+div_name).addClass("loading");
			showImage(n);
		} else { 
			changeImage();
		}
	}
	
	function showImage(src)
	{
		$("#"+div_name+" img").fadeOut(500);
		var largeImage = new Image();
		$(largeImage).load(function()
							{
								$(this).hide();
								$("#"+div_name).append(this).removeClass("loading");
												 
								$(this).fadeIn(1100);              
							});    
		$(largeImage).attr("src", src);                                                                               
	}
	
	function checkForLoaded () {
		if (document.getElementById(div_name) != null) {
			//alert("loaded");
			clearInterval(timer);
			changeImage();
			timer = setInterval(changeImage, (seconds_between_photos * 1000));
		}
	}
	
	timer = setInterval(checkForLoaded, 500); 

}

function slide3() {	
	
	var myImages = ['slide_pictures/pic21.jpg','slide_pictures/pic22.jpg','slide_pictures/pic23.jpg','slide_pictures/pic24.jpg','slide_pictures/pic25.jpg','slide_pictures/pic26.jpg','slide_pictures/pic27.jpg','slide_pictures/pic28.jpg','slide_pictures/pic29.jpg','slide_pictures/pic30.jpg'];
	
	// how many times should the photo change per page load
	var maxChanges = myImages.length * 30;
	
	// shuffle images so each time page loads, the photos show in different order
	var do_shuffle = true;
	
	// use simple randomness instead of shuffling (tends to repeat images too often)
	var do_randomly = false;
	
	// number of seconds between photo changes
	var seconds_between_photos = 8;
	
	// name of DIV to load photos into
	var div_name = "slideshow3";
	
	var changes = 0;
	var timer;
	var thisImg = myImages.length - 1;
	
	shuffle = function(o){ 
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	};
	
	if (do_shuffle) {
		myImages = shuffle(myImages);	
	}
	
	function nextImage () {
		
		var low = 0;
		var high = myImages.length - 1;
		var rand_no = Math.floor((high-(low - 1))*Math.random()) + low;
		
		thisImg++;
		changes++;
		if (thisImg==myImages.length) {
			thisImg = 0;
		}
		if (changes==maxChanges) {
			clearInterval(timer);
		}
		if (do_randomly) {
			thisImg = rand_no;
			return myImages[rand_no];
		} else {
			return myImages[thisImg];
		}
	}
	
	function changeImage () {
		
		var t = myImages[thisImg];
		var n = nextImage();
		
		if (t != n) {
			$("#"+div_name).addClass("loading");
			showImage(n);
		} else { 
			changeImage();
		}
	}
	
	function showImage(src)
	{
		$("#"+div_name+" img").fadeOut(500);
		var largeImage = new Image();
		$(largeImage).load(function()
							{
								$(this).hide();
								$("#"+div_name).append(this).removeClass("loading");
												 
								$(this).fadeIn(1100);              
							});    
		$(largeImage).attr("src", src);                                                                               
	}
	
	function checkForLoaded () {
		if (document.getElementById(div_name) != null) {
			//alert("loaded");
			clearInterval(timer);
			changeImage();
			timer = setInterval(changeImage, (seconds_between_photos * 1000));
		}
	}
	
	timer = setInterval(checkForLoaded, 500); 

}

function slide4() {	
	
	var myImages = ['slide_pictures/pic31.jpg','slide_pictures/pic32.jpg','slide_pictures/pic33.jpg','slide_pictures/pic34.jpg','slide_pictures/pic35.jpg','slide_pictures/pic36.jpg','slide_pictures/pic37.jpg','slide_pictures/pic38.jpg','slide_pictures/pic39.jpg','slide_pictures/pic40.jpg'];
	
	// how many times should the photo change per page load
	var maxChanges = myImages.length * 30;
	
	// shuffle images so each time page loads, the photos show in different order
	var do_shuffle = true;
	
	// use simple randomness instead of shuffling (tends to repeat images too often)
	var do_randomly = false;
	
	// number of seconds between photo changes
	var seconds_between_photos = 11;
	
	// name of DIV to load photos into
	var div_name = "slideshow4";
	
	var changes = 0;
	var timer;
	var thisImg = myImages.length - 1;
	
	shuffle = function(o){ 
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	};
	
	if (do_shuffle) {
		myImages = shuffle(myImages);	
	}
	
	function nextImage () {
		
		var low = 0;
		var high = myImages.length - 1;
		var rand_no = Math.floor((high-(low - 1))*Math.random()) + low;
		
		thisImg++;
		changes++;
		if (thisImg==myImages.length) {
			thisImg = 0;
		}
		if (changes==maxChanges) {
			clearInterval(timer);
		}
		if (do_randomly) {
			thisImg = rand_no;
			return myImages[rand_no];
		} else {
			return myImages[thisImg];
		}
	}
	
	function changeImage () {
		
		var t = myImages[thisImg];
		var n = nextImage();
		
		if (t != n) {
			$("#"+div_name).addClass("loading");
			showImage(n);
		} else { 
			changeImage();
		}
	}
	
	function showImage(src)
	{
		$("#"+div_name+" img").fadeOut(500);
		var largeImage = new Image();
		$(largeImage).load(function()
							{
								$(this).hide();
								$("#"+div_name).append(this).removeClass("loading");
												 
								$(this).fadeIn(1100);              
							});    
		$(largeImage).attr("src", src);                                                                               
	}
	
	function checkForLoaded () {
		if (document.getElementById(div_name) != null) {
			//alert("loaded");
			clearInterval(timer);
			changeImage();
			timer = setInterval(changeImage, (seconds_between_photos * 1000));
		}
	}
	
	timer = setInterval(checkForLoaded, 500); 

}

function slide5() {	
	
	var myImages = ['slide_pictures/pic41.jpg','slide_pictures/pic42.jpg','slide_pictures/pic43.jpg','slide_pictures/pic44.jpg','slide_pictures/pic45.jpg','slide_pictures/pic46.jpg','slide_pictures/pic47.jpg','slide_pictures/pic48.jpg','slide_pictures/pic49.jpg','slide_pictures/pic50.jpg'];
	
	// how many times should the photo change per page load
	var maxChanges = myImages.length * 30;
	
	// shuffle images so each time page loads, the photos show in different order
	var do_shuffle = true;
	
	// use simple randomness instead of shuffling (tends to repeat images too often)
	var do_randomly = false;
	
	// number of seconds between photo changes
	var seconds_between_photos = 9;
	
	// name of DIV to load photos into
	var div_name = "slideshow5";
	
	var changes = 0;
	var timer;
	var thisImg = myImages.length - 1;
	
	shuffle = function(o){ 
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	};
	
	if (do_shuffle) {
		myImages = shuffle(myImages);	
	}
	
	function nextImage () {
		
		var low = 0;
		var high = myImages.length - 1;
		var rand_no = Math.floor((high-(low - 1))*Math.random()) + low;
		
		thisImg++;
		changes++;
		if (thisImg==myImages.length) {
			thisImg = 0;
		}
		if (changes==maxChanges) {
			clearInterval(timer);
		}
		if (do_randomly) {
			thisImg = rand_no;
			return myImages[rand_no];
		} else {
			return myImages[thisImg];
		}
	}
	
	function changeImage () {
		
		var t = myImages[thisImg];
		var n = nextImage();
		
		if (t != n) {
			$("#"+div_name).addClass("loading");
			showImage(n);
		} else { 
			changeImage();
		}
	}
	
	function showImage(src)
	{
		$("#"+div_name+" img").fadeOut(500);
		var largeImage = new Image();
		$(largeImage).load(function()
							{
								$(this).hide();
								$("#"+div_name).append(this).removeClass("loading");
												 
								$(this).fadeIn(1100);              
							});    
		$(largeImage).attr("src", src);                                                                               
	}
	
	function checkForLoaded () {
		if (document.getElementById(div_name) != null) {
			//alert("loaded");
			clearInterval(timer);
			changeImage();
			timer = setInterval(changeImage, (seconds_between_photos * 1000));
		}
	}
	
	timer = setInterval(checkForLoaded, 500); 

}

function slide6() {	
	
	var myImages = ['slide_pictures/pic51.jpg','slide_pictures/pic52.jpg','slide_pictures/pic53.jpg','slide_pictures/pic54.jpg','slide_pictures/pic55.jpg','slide_pictures/pic56.jpg','slide_pictures/pic57.jpg','slide_pictures/pic58.jpg','slide_pictures/pic59.jpg','slide_pictures/pic60.jpg','slide_pictures/pic61.jpg','slide_pictures/pic62.jpg'];
	
	// how many times should the photo change per page load
	var maxChanges = myImages.length * 30;
	
	// shuffle images so each time page loads, the photos show in different order
	var do_shuffle = true;
	
	// use simple randomness instead of shuffling (tends to repeat images too often)
	var do_randomly = false;
	
	// number of seconds between photo changes
	var seconds_between_photos = 7;
	
	// name of DIV to load photos into
	var div_name = "slideshow6";
	
	var changes = 0;
	var timer;
	var thisImg = myImages.length - 1;
	
	shuffle = function(o){ 
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	};
	
	if (do_shuffle) {
		myImages = shuffle(myImages);	
	}
	
	function nextImage () {
		
		var low = 0;
		var high = myImages.length - 1;
		var rand_no = Math.floor((high-(low - 1))*Math.random()) + low;
		
		thisImg++;
		changes++;
		if (thisImg==myImages.length) {
			thisImg = 0;
		}
		if (changes==maxChanges) {
			clearInterval(timer);
		}
		if (do_randomly) {
			thisImg = rand_no;
			return myImages[rand_no];
		} else {
			return myImages[thisImg];
		}
	}
	
	function changeImage () {
		
		var t = myImages[thisImg];
		var n = nextImage();
		
		if (t != n) {
			$("#"+div_name).addClass("loading");
			showImage(n);
		} else { 
			changeImage();
		}
	}
	
	function showImage(src)
	{
		$("#"+div_name+" img").fadeOut(500);
		var largeImage = new Image();
		$(largeImage).load(function()
							{
								$(this).hide();
								$("#"+div_name).append(this).removeClass("loading");
												 
								$(this).fadeIn(1100);              
							});    
		$(largeImage).attr("src", src);                                                                               
	}
	
	function checkForLoaded () {
		if (document.getElementById(div_name) != null) {
			//alert("loaded");
			clearInterval(timer);
			changeImage();
			timer = setInterval(changeImage, (seconds_between_photos * 1000));
		}
	}
	
	timer = setInterval(checkForLoaded, 500); 

}

function slide7() {	
	
	var myImages = ['slide_pictures/pic1.jpg','slide_pictures/pic2.jpg','slide_pictures/pic3.jpg','slide_pictures/pic4.jpg','slide_pictures/pic5.jpg','slide_pictures/pic6.jpg','slide_pictures/pic7.jpg','slide_pictures/pic8.jpg','slide_pictures/pic9.jpg','slide_pictures/pic10.jpg'];
	
	// how many times should the photo change per page load
	var maxChanges = myImages.length * 30;
	
	// shuffle images so each time page loads, the photos show in different order
	var do_shuffle = true;
	
	// use simple randomness instead of shuffling (tends to repeat images too often)
	var do_randomly = false;
	
	// number of seconds between photo changes
	var seconds_between_photos = 9;
	
	// name of DIV to load photos into
	var div_name = "slideshow7";
	
	var changes = 0;
	var timer;
	var thisImg = myImages.length - 1;
	
	shuffle = function(o){ 
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	};
	
	if (do_shuffle) {
		myImages = shuffle(myImages);	
	}
	
	function nextImage () {
		
		var low = 0;
		var high = myImages.length - 1;
		var rand_no = Math.floor((high-(low - 1))*Math.random()) + low;
		
		thisImg++;
		changes++;
		if (thisImg==myImages.length) {
			thisImg = 0;
		}
		if (changes==maxChanges) {
			clearInterval(timer);
		}
		if (do_randomly) {
			thisImg = rand_no;
			return myImages[rand_no];
		} else {
			return myImages[thisImg];
		}
	}
	
	function changeImage () {
		
		var t = myImages[thisImg];
		var n = nextImage();
		
		if (t != n) {
			$("#"+div_name).addClass("loading");
			showImage(n);
		} else { 
			changeImage();
		}
	}
	
	function showImage(src)
	{
		$("#"+div_name+" img").fadeOut(500);
		var largeImage = new Image();
		$(largeImage).load(function()
							{
								$(this).hide();
								$("#"+div_name).append(this).removeClass("loading");
												 
								$(this).fadeIn(1100);              
							});    
		$(largeImage).attr("src", src);                                                                               
	}
	
	function checkForLoaded () {
		if (document.getElementById(div_name) != null) {
			//alert("loaded");
			clearInterval(timer);
			changeImage();
			timer = setInterval(changeImage, (seconds_between_photos * 1000));
		}
	}
	
	timer = setInterval(checkForLoaded, 500); 

}

function slide8() {	
	
	var myImages = ['slide_pictures/pic11.jpg','slide_pictures/pic12.jpg','slide_pictures/pic13.jpg','slide_pictures/pic14.jpg','slide_pictures/pic15.jpg','slide_pictures/pic16.jpg','slide_pictures/pic17.jpg','slide_pictures/pic18.jpg','slide_pictures/pic19.jpg','slide_pictures/pic20.jpg'];
	
	// how many times should the photo change per page load
	var maxChanges = myImages.length * 30;
	
	// shuffle images so each time page loads, the photos show in different order
	var do_shuffle = true;
	
	// use simple randomness instead of shuffling (tends to repeat images too often)
	var do_randomly = false;
	
	// number of seconds between photo changes
	var seconds_between_photos = 7;
	
	// name of DIV to load photos into
	var div_name = "slideshow8";
	
	var changes = 0;
	var timer;
	var thisImg = myImages.length - 1;
	
	shuffle = function(o){ 
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	};
	
	if (do_shuffle) {
		myImages = shuffle(myImages);	
	}
	
	function nextImage () {
		
		var low = 0;
		var high = myImages.length - 1;
		var rand_no = Math.floor((high-(low - 1))*Math.random()) + low;
		
		thisImg++;
		changes++;
		if (thisImg==myImages.length) {
			thisImg = 0;
		}
		if (changes==maxChanges) {
			clearInterval(timer);
		}
		if (do_randomly) {
			thisImg = rand_no;
			return myImages[rand_no];
		} else {
			return myImages[thisImg];
		}
	}
	
	function changeImage () {
		
		var t = myImages[thisImg];
		var n = nextImage();
		
		if (t != n) {
			$("#"+div_name).addClass("loading");
			showImage(n);
		} else { 
			changeImage();
		}
	}
	
	function showImage(src)
	{
		$("#"+div_name+" img").fadeOut(500);
		var largeImage = new Image();
		$(largeImage).load(function()
							{
								$(this).hide();
								$("#"+div_name).append(this).removeClass("loading");
												 
								$(this).fadeIn(1100);              
							});    
		$(largeImage).attr("src", src);                                                                               
	}
	
	function checkForLoaded () {
		if (document.getElementById(div_name) != null) {
			//alert("loaded");
			clearInterval(timer);
			changeImage();
			timer = setInterval(changeImage, (seconds_between_photos * 1000));
		}
	}
	
	timer = setInterval(checkForLoaded, 500); 

}

function start() { 
	slide1(); 
	slide2();
	slide3();
	slide4();
	slide5();
	slide6();
	slide7();
	slide8();
} 
	 
window.onload = start; 


/*
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$.preloadImages("slide_pictures/pic1.jpg", "slide_pictures/pic2.jpg", "slide_pictures/pic3.jpg", "slide_pictures/pic4.jpg", "slide_pictures/pic5.jpg", "slide_pictures/pic6.jpg", "slide_pictures/pic7.jpg", "slide_pictures/pic8.jpg", "slide_pictures/pic9.jpg");
*/