﻿var photos = new Array("AmyB","GeofreyK","AndreaG","Photo7","BradW","BrockS","CherysE","CibeleM","Photo3","ColinS","ColsonB","DaniC","Photo4","GobarB","JamieK","KarenM","KellyB","EthanK","KoleS","LarryB","LeahS","MalloryB","MrsB","PaigeS","PurnaB","RuthT","Photo2","SaraS","JustineK","ShaneC","SkipB","TerrylS","WillowC");	   
				
var idx=0; 
var imgidx=0;
var IntervalSecs = 3;
var NumPhotos;
var imgArray;
var startImg;

function showImage() {
  idx=idx+1;
  if(idx==photos.length) // Reset index if over the max no of images 
  { 
	idx=0; 
  } 

  imgidx=imgidx+1;
  if(imgidx>NumPhotos) // Reset index if over the max no of images on page
  { 
	imgidx=1; 
  } 

  var mimg=document.getElementById("img"+imgidx); 

  mimg.setAttribute("src","images/"+photos[idx]+".jpg"); 

  // Set the timer to display next image 
  setTimeout("showImage()", IntervalSecs*1000); 

} 

function initPhotos(num) { 
  NumPhotos = num;

  if (NumPhotos == 8) {
      imgArray = new Array(5,1,8,3,2,4,6,7);
  } 
  else if (NumPhotos == 12) {
      imgArray = new Array(5,1,8,3,11,9,2,4,12,6,10,7);
  } 
  else if (NumPhotos == 14) {
      imgArray = new Array(5,1,13,8,3,11,9,2,14,4,12,6,10,7);
  }  
  else if (NumPhotos == 18) {
      imgArray = new Array(5,15,1,13,8,16,3,11,9,17,2,14,4,12,6,18,10,7);
  }  
  
  idx = Math.floor(Math.random()*photos.length+1);
  
  if (photos.length-1 - NumPhotos < idx) {
    idx = photos.length-1 - NumPhotos;
  }

  setTimeout("showImage()", IntervalSecs*1000); 
  
}

function initLeftImages() {
	var limit = NumPhotos/2;

	for (var loopvar=0; loopvar<limit; loopvar++) {
	    document.write("<img id=\"img"+imgArray[loopvar]+"\" src=\"images/"+photos[idx++]+".jpg\" border=\"0\" width=\"75\" /><br />");
        //idx = idx + 1;
    }
}

function initRightImages() {
	var limit = NumPhotos/2;

	for (var loopvar=0; loopvar<limit; loopvar++) {
	    document.write("<img id=\"img"+imgArray[loopvar+limit]+"\" src=\"images/"+photos[idx++]+".jpg\" border=\"0\" width=\"75\" /><br />");
        //idx = idx + 1;
    }
}


