<!--//

// Constants
var cycle = false;
var delay = 3000;

// Variables
var currentimage = 0;
var bigimage;
var bigimagecaption_div;
var run;

var isDOM = ( document.getElementById ? true : false ); 
var isIE4 = ( document.all && !isDOM ? true : false );
var isNS4 = ( document.layers ? true : false );

function getRef(id)
{
 if ( isDOM ) return document.getElementById( id );
 if ( isIE4 ) return document.all[id];
 if ( isNS4 ) return document.layers[id];
}

function init()
{
	var bigimagediv = getRef( 'slideshow' );
	bigimage = bigimagediv.getElementsByTagName( 'img' )
	bigimage[0].name="slideshow";
	
	bigimagecaption_div = getRef( 'slideshowcaption' );
	
	slideShow();
}

var lengthvar = ImageArray.length - 1;

function changeImage( amounttochange ) 
{	
	if ( document.images ) 
	{
		currentimage = currentimage + amounttochange;
		
		setImageIndex( currentimage );
   	}
}

function setImageIndex( imageIndex ) 
{	
	if ( document.images ) 
	{
		currentimage = imageIndex;
		
		if ( currentimage > lengthvar ) 
		{
			currentimage = 0;
		}
		
		if ( currentimage < 0) 
		{
			currentimage = lengthvar;
		}
		
		bigimage[0].src = ImageArray[currentimage];
		

		if ( window.ImageWidthArray )
		{
			
			bigimage[0].width = ImageWidthArray[currentimage];
			bigimage[0].height = ImageHeightArray[currentimage];
			//alert ("width array found; currentimage " + currentimage + " new dimensions: " + ImageWidthArray[currentimage] +"x"+ ImageHeightArray[currentimage]);
		}
//alert ("Array exist? " + window.ImageWidthArray);
//alert ( bigimage[0].src + " " );
//alert (ImageWidthArray[currentimage] + " = " + bigimage[0].width);
//alert (ImageHeightArray[currentimage] + " = " + bigimage[0].height);


		if ( window.ImageCaptionArray )
		{
			if ( bigimagecaption_div )
			{
				var caption = ImageCaptionArray[currentimage];
				bigimagecaption_div.innerHTML = caption;
			}
		
		}
		
   	}
}


function slideShow( setState )
{
	if ( setState == 'run' )
	{		
		if ( !cycle )
			cycle = true;
		else
			return; // nothing to do
	}
	else if ( setState == 'stop' )
	{
		if ( cycle )
			cycle = false;
		else
			return; // nothing to do
	}
	else	// toggle cycle state
	{
		cycle = !cycle;
	}
		
	if ( cycle )
		run = setInterval( "changeImage(1)", delay );	
	else
		window.clearInterval( run );
			
	
}

//-->

