// Number of touts
ToutCount = 9

// Set initial variables
toutLink = 1;

speed = 4000;
timer = "off";

ToutTabs = new MakeImageArray(9);
ToutImages = new MakeImageArray(9);
ToutLinks = new Array(9);
TabLinks = new Array(9);


// This function loads the images once the rest of the page has loaded and starts the cycling function.
// When new images are put in, change the file names here

function kickstart() {

	if (document.images) 
	{
// This is the first tout.
// It retrieves it from the src attribute of the img tag.
		ToutImages[1].src = document.images["toutImage"].src;
			
		
// These are the preceeding links
	  	ToutImages[1].src = "images/gallery/1.jpg";
		ToutImages[2].src = "images/gallery/2.jpg";
		ToutImages[3].src = "images/gallery/3.jpg";
		ToutImages[4].src = "images/gallery/4.jpg";
		ToutImages[5].src = "images/gallery/5.jpg";
		ToutImages[6].src = "images/gallery/6.jpg";
		ToutImages[7].src = "images/gallery/7.jpg";
		ToutImages[8].src = "images/gallery/8.jpg";
		ToutImages[9].src = "images/gallery/9.jpg";
		
	} //end if document.images
} // end function kickstart


function MakeImageArray(n) {
  	this.length = n;
  	if (document.images) 
	{
	  	for (var i = 1; i<=n; i++) {
	    	this[i] = new Image();
	  	}
  	}
  	return this;  
}

function getNextTout() {

  if (document.images){
    	toutNext = toutLink + 1;
		if (toutNext > ToutCount)
		{ 
			toutNext = 1;
		}
		toutLink = toutNext;
		document.images["toutImage"].src = ToutImages[toutNext].src;
  }
  return false;
}
function getPrevTout() {

  if (document.images){
    	toutPrev = toutLink - 1;
		if (toutPrev < 1)
		{ 
			toutPrev = ToutCount;
		}
		toutLink = toutPrev;
		document.images["toutImage"].src = ToutImages[toutPrev].src;
  }
  return false;
}

function getToutLink() {

  window.open(ToutLinks[toutLink])
}
