//var x is the length of the images array minus 1
//var a comes from the id of the image that calls the function
//var b is the name of the Image Array that the function calls
//var d is the name of an array of strings -comments that appear below the images
//var direction is usually set to 1 or -1 to move the slide show formard and back, 
// and set to -i to bring back to the start and used to be +i to go to the end,
// but  you cannot put '+i' for the argument to fast foreward, rather you need to 
// put the same number as is in the x variable, but you can't USE the x variable there.
// THe first argument of startAuto() lets you set how long it takes before it changes the first image switch
// the second argument of startAuto() enables you to choose the delay rate for all subsequent images
// I multiplied those 2 arguments by 1000 in the script, so that you can just use seconda in the calling pages
var i = 0;
var ImgNum = 0;
var counter = 0;
function chgImg(direction,x,b,d) {
this.direction = direction;
this.x = x;
this.b = b;
this.d = d;
if (document.images) {
proceed();

	}
}
function proceed() {
	if (document.images) {
var a = document.getElementById( 'slideshow' );
var blahBlah = document.getElementById( 'imgComments' );
var contents = d;
i = x;
var ImgLength = b.length - 1;
ImgNum = ImgNum + direction;
counter = i
if (ImgNum > ImgLength) {
ImgNum = i;
}
//alert(ImgNum);
if (ImgNum < 0) {
ImgNum = 0;
}
//alert(ImgNum);
// the delay of the following setTimeout controls the changing of the first image
// see line 76 to control the length of time on subsequent images
setTimeout( 'tweedledee()');
   }
if( navigator.appName == 'Opera' ) {
blahBlah.setAttribute( 'style', 'font-size: 1.3em; width: 700px; text-align: center' );
//blahBlah.style.font-size = '2em':
//alert(blahBlah)
	}
}
//the argument 'd' is the image comments from the imgDescript array on the calling page
function tweedledee() {
var a = document.getElementById( 'slideshow' );
var contents = d;
a.src = p + b[ImgNum];
document.getElementById( 'imgComments' ).innerHTML = contents[ImgNum];
//alert(ImgNum);
}

function clear() {
  /*
   * Description: Method of buttonSet object. Used to reset any global
   *              variables on which any buttons in the buttonSet rely
   *              on for their condition statements.
   * Arguments: None.
   */
   gIsRunning=false;
}
var gTimer = 0;
//alert( gTimer );
function startAuto(start,delay) {
this.delay = delay;
this.start = start;
//alert( start );
  /*
   * Description: Start a "slideshow".
   * Arguments: Start and Delay
   */
   if ((start > 0) && (counter > ImgNum-1)) {
   		setTimeout("chgImg(1,x,b,d)",(start*1000));
  		 gTimer = setTimeout("startAuto(start,delay)",(delay*1000));
  		//THe above delay controls the length of time on subsequent images
  		 //alert(ImgNum);
	}
}

	function eliminateVoodoo(stop)  { 
	if (stop == 1){
		window.clearTimeout(gTimer);
	}
}
