var path = "site_images/";  // the path where the page lives.

// load the images.
slide1 = new Image(); slide1.src = path + "swap1.jpg";
slide2 = new Image(); slide2.src = path + "swap2.jpg";
slide3 = new Image(); slide3.src = path + "swap3.jpg";
slide4 = new Image(); slide4.src = path + "swap4.jpg";
slide5 = new Image(); slide5.src = path + "swap5.jpg";
slide6 = new Image(); slide6.src = path + "swap6.jpg";
slide7 = new Image(); slide7.src = path + "swap7.jpg";
slide8 = new Image(); slide8.src = path + "swap8.jpg";
slide9 = new Image(); slide9.src = path + "swap9.jpg";
slide10 = new Image(); slide10.src = path + "swap10.jpg";
slide11 = new Image(); slide11.src = path + "swap11.jpg";


// set up the global variables.
var NumSlides = 11;  // change this to match the number of slides!
var current = 1;    // slide to start with.
var Maxtime = 10; //Maximum time between swaps
var yM_Timer;    // the timer variable.
var rand1
var name1
var name2
var name3

function next(num){  // randomly select a slide from the array
	var randomnumber = Math.random() ;	
	var num = Math.round( (NumSlides -1) * randomnumber) + 1 ;
	return num;
	}


// This is the function that's executed after the delay time is up.
function LoadNext1(currentIndex) {
// get the new slide index and swap current image.
	newIndex = next(currentIndex);
	current = newIndex;
	swap1(newIndex);
	}

function swap1(name){
	// function to do the image swap .  
	var randomnumber = Math.random() ;	
	var TimeDelay = Math.round( (Maxtime -1) * randomnumber) + 1 ;	
	name1 = name
	if (name2 == name || name3 == name){
		LoadNext1(" + name + ");
		return false;
		}
	document.swapimage1.src = eval("slide" + name + ".src");
	yM_Timer=setTimeout("LoadNext1(" + name + ")",TimeDelay*1000);
        } 


function LoadNext2(currentIndex) {
// get the new slide index and swap current image.
	newIndex = next(currentIndex);
	current = newIndex;
	swap2(newIndex);
	}
	
function swap2(name){
	// function to do the image swap .  
	var randomnumber = Math.random() ;	
	var TimeDelay = Math.round( (Maxtime -1) * randomnumber) + 1 ;
	name2 = name;
	if (name1 == name || name3 == name){
		LoadNext2(" + name + ");
		return false;
		}
	//alert('no 2: ' + name2 + ' - no 1: ' + name1);
	document.swapimage2.src = eval("slide" + name + ".src");
	yM_Timer=setTimeout("LoadNext2(" + name + ")",TimeDelay*1000);
        } 

function LoadNext3(currentIndex) {
// get the new slide index and swap current image.
	newIndex = next(currentIndex);
	current = newIndex;
	swap3(newIndex);
	}
	
function swap3(name){
	// function to do the image swap .  
	var randomnumber = Math.random() ;	
	var TimeDelay = Math.round( (Maxtime -1) * randomnumber) + 1 ;
	name3 = name;
	if (name1 == name || name2 == name){
		LoadNext3(" + name + ");
		return false;
		}
	document.swapimage3.src = eval("slide" + name + ".src");
	yM_Timer=setTimeout("LoadNext3(" + name + ")",TimeDelay*1000);
        } 
