// JavaScript Document
<!-- ALTERNATING IMAGE BOX -->

/*

Modified by Chris K. Hatton (c) 2010

-- ALTERNATING MESSAGE TEXT BOX --
Copyright 2001, Sandeep Gangadharan
For more free scripts go to http://sivamdesign.com/scripts/
source: http://www.sivamdesign.com/scripts/dwld/altmess.txt

Also used code from http://www.secretgeek.net/fajax.asp - for the fading effect

*/

var image = 0;			// this is the starting point
var DisTime = 8000;		// this is the display time in milliseconds
var waitTime = 1200;	// this is the pause before a new image appears in milliseconds
var stopswitch;			// intates a stop when the value = 1



function displayImage() {
	if (theimage.length > 0) {
  		document.getElementById("imagehere").innerHTML = theimage[image];	// this changes the HTML inside what ever tag it's attached to
  		document.getElementById("pageimagetitle").src = imagetitle[image];	// this changes the HTML inside what ever tag it's attached to
		inVis();
		fadeIn();
		check();		// check button highlight/colour
	}
	window.setTimeout("changeImage()", DisTime);
}

function changeImage() {
	if (!stopswitch == 1) {
		Vis();
		fadeOut();
		image++;		// increment image number by 1
		if (image == imageCnt) {		// reset if the same
			image = 0;
		}
		setTimeout("displayImage();", waitTime);
	}
}



<!-- fading in and out of each image -->

function inVis() {
	document.getElementById('imagehere').style.opacity=0.1; // initialise
}

function Vis() {
	document.getElementById('imagehere').style.opacity=0.9; // initialise
}

function fadeIn() {

	var bodyStyle=document.getElementById('imagehere').style;

	if ( bodyStyle.opacity < 1) {
		bodyStyle.opacity=((bodyStyle.opacity*10)+1)/10; //Add 0.1
		setTimeout('fadeIn();',100)
		}
}

function fadeOut() {

	var bodyStyle=document.getElementById('imagehere').style;

	if ( bodyStyle.opacity > 0) {
		bodyStyle.opacity=((bodyStyle.opacity*10)-1)/10; //Subtract 0.1
		setTimeout('fadeOut();',100)
		}
}



<!-- control -->

function stopchange() {
	stopswitch = 1;
	Effect.Appear('play');
	check();
}

function startchange() {
	Effect.Fade('play', { duration: 1.0 });
	stopswitch = 0;
	changeImage();
}

function closeblurb() {
	Effect.Fade('imageblurb', { duration: 0.5 });
	Effect.Appear('blurbbutton', { duration: 0.5 });
}

function openblurb() {
	Effect.Fade('blurbbutton', { duration: 0.5 });
	Effect.Appear('imageblurb', { duration: 0.5 });
}
