
// image.js // 02/15/01,11/23/00,07/25/00,12/12/1999.
// Copyright Gene Dumas
// Local Global vars.
var iNDX = 1;	// Image array index, begin with 2nd one.
var aIMAGENAMES;	// = new Array();	// Array of image names.
var aMYIMAGES;	// = new Array();

function createNames() {
var aString = new Array();
var iNum = iENDNUM - iSTARTNUM + 1;	// Num of images.
var j = iSTARTNUM;

for (var i=0; i<iNum; i++) {	// Create name, add to array.
	aString[i] = cPREFIX + j++ + cSUFFIX;
}
return aString;
}

function preLoad(aImgNames) {

var aImgSrc = new Array();
var k = aImgNames.length;

if ( window.document.images ) { // Image swaps or rollovers can work.
	for ( var i = 0; i < k; i++ ) {
		aImgSrc[i] = new Image();
		aImgSrc[i].src = cPATH + aImgNames[i] + cEXT;
	}
}
else {
	who();
}

return aImgSrc;
}

function over(imgName) {

// Find imgName in aIMAGENAMES.
for (var i = 0; i < aIMAGENAMES.length; i++) {
	if ( imgName == aIMAGENAMES[i] ){
		document.Image1.src = aMYIMAGES[i].src;
		i = aIMAGENAMES.length;
	}
}

}

function dispImage(imgName) {

document.Image1.src = cPATH + imgName + cEXT;
}

function displayImage() {

var myImage = new Image();

if (!OKAY) {
	return true; // Just leave unless okay.
}
// Switch image names.
myImage.src = cPATH + aIMAGENAMES[iNDX++] + cEXT;
if ( iNDX == aIMAGENAMES.length ) { // End of array.
	iNDX = 0; // Start at beginning of array.
}
// Assign the new image to a spot on the document
// that is occupied by the image defined as currentImage.
//eval("r" + name  + ".src = '" + cPATH + name + cEXT + "'");
document.currentImage.src = myImage.src;
}

function browserChk() {

var code, version, iver;

// Find out what browser this is.
with(navigator) {
	code = appCodeName;
	version = appVersion; 
	iver = parseInt(version); 
	}
// This will work in "Mozilla" 3+ (includes MSIE 4)
if ( code == "Mozilla" && iver >= 3 ) OKAY = true;
else OKAY = false;

return OKAY;
}

function accessImage() {

// The image that you display is the Image1
alert("Src = " + document.Image1.src +
"\nWidth  = " + document.Image1.width  +
"\nHeight = " + document.Image1.height +
"\nBorder = " + document.Image1.border +
"\nHspace = " + document.Image1.hspace +
"\nVspace = " + document.Image1.vspace +
"\nImageTagName = " + document.Image1.name +
"\nComplete = " + document.Image1.complete +
"\nLowsrc = " + document.Image1.lowsrc +
"\nPrototype = " + document.Image1.prototype +
"\nOnerror = " + document.Image1.onerror );
}

function who() {

var code, app, version, iver, ua;

// Find out what browser this is.
with(navigator) {
	code = appCodeName; 
	app = appName; 
	version = appVersion; 
	iver = parseInt(version); 
	ua = userAgent;
	}
// ua string is a generalized printable string
uastring = app + " " + iver;
	alert("This works in Mozilla 3+." +
	"\nAppCodeName = " + code +
	"\nAppName = " + app +
	"\nAppVersion = " + version +
	"\nVersionNo. = " + iver +
	"\nUserAgent = " + ua +
	"\nUsable Browser = " + OKAY);
}

function initImages() {

OKAY = browserChk();		// Find out what browser this is.
if ( OKAY ){
	aIMAGENAMES = createNames();  // Load names of images in array.
	aMYIMAGES = preLoad(aIMAGENAMES);	// Load images into memory.
}
else {
	who();
}

}
// Eof
