A copy of the JavaScript functions in the head element:
// sample-2-slideshow-functions.js
// global variables
var currentImage = 0;
var timerName = "";
// The Image objects are created in the array and their src is specified
// Creating the Image objects and their src property values causes
// the images to preload into the cache
var images = new Array();
images[0] = new Image();
images[0].src = "../images/i0.gif";
images[1] = new Image();
images[1].src = "../images/i1.gif";
images[2] = new Image();
images[2].src = "../images/i2.gif";
images[3] = new Image();
images[3].src = "../images/i3.gif";
images[4] = new Image();
images[4].src = "../images/i4.gif";
images[5] = new Image();
images[5].src = "../images/i5.gif";
// changeImage to the next image
function changeImage()
{
if (document.image.complete)
{
currentImage = ++currentImage % images.length
imageReference = document.getElementById("image");
imageReference.src = images[currentImage].src;
}
}
// onmouseover event handler
function loaded()
{
var result_area = document.getElementById("result");
result_area.value = "load event occurred";
}
// onmouseover event handler
function mouse()
{
var result_area = document.getElementById("result");
result_area.value = "mouseover event occurred";
}
// alternate mouseover event handler
// only works for the specified location of the result area
// the first childNodes[1] gets the div element (in the body)
// the second childNodes[1] gets the input element (in the div)
function alternate_onmouseover()
{
document.body.childNodes[1].childNodes[1].value = "mouseover event occurred";
}
// onmouseout event handler
function mouseout()
{
var result_area = document.getElementById("result");
result_area.value = "mouseout event occurred";
}
// onclick event handler to start image cycle
function clicked1()
{
var result_area = document.getElementById("result");
result_area.value = "click event occurred";
if (!timerName)
{
timerName = setInterval("changeImage()", 750);
}
}
// onclick event handler to stop image cycle
function clicked2()
{
var result_area = document.getElementById("result");
result_area.value = "click event occurred";
clearInterval(timerName);
timerName = false;
}