
// image.js // Revised: 022310,121907,111007,021501,112300,
// 07252000,12121999.//
// Copyright Gene Dumas


var OKAY = false; // This MUST be the first line of code!
// OKAY prevents the rollovers from trying to run before the code
// is all initialized. See rollover.js for instructions.

/* Global variables defined on calling page.
var cPATH = "photos/";	// "images/"; Image Path (Include the trailing "/".)
var cPREFIX = "100_";
var cSUFFIX = "";
var cEXT = ".jpg";
var iSTARTNUM = 1;	//1747;
var iENDNUM = 24;	//1786;
var iFILSIZE = 1.267;	// Average for each file in MB.
var msgWINDOW;
*/


// Object Methods for image on the page with name = 'IMAGE01' -//

var oIMAGES1;	// Global var for the image object

function nextImg() {

	var iNext,the_image_src;

	iNext = this.ndx + 1;
	if (iNext == this.names.length) iNext = 0;
	the_image_src = this.names[iNext].src;
	document.IMAGE01.src = the_image_src;
	// Works only w/ img name=IMAGE01 not id=IMAGE01
	//document.images[0].src = the_image;
	//document.images.IMAGE01.src='dd2.gif';
	
	this.ndx = iNext;
}

function prevImg() {

	var iNext,the_image_src;

	iNext = this.ndx - 1;
	if (iNext == -1) iNext = this.names.length - 1;
	the_image_src = this.names[iNext].src;
	document.IMAGE01.src = the_image_src;
	this.ndx = iNext;
}

// Constructor function to define an object type,
// that specifies its name, properties, and methods.
function ImgConst(aNames, iNdx) {

	this.names = aNames || [];
	this.ndx = iNdx || 0;
	this.disp = nextImg;
	this.prev = prevImg;
}
//	this.imgLoad = preLoad || [];

// function loadImages() {

// oIMAGES1.imgLoad; // Load images into memory.

// }

function AddPath(cPath, aFilnams) {

var i;
var k = aFilnams.length;

	for ( i = 0; i < k; i++ ) {
		aFilnams[i] = cPath + aFilnams[i];
	}

return aFilnams;

}

function imagesSet(cPath,aFilNames,preLd) {

var aImageSrc;
var iWidth, iHeight, iAvailW, iAvailH;

if (document.images) {
	//defaultStatus='Click Center Image for Latest Creations!';

if (preLd) {
	//defaultStatus = 'Loading images into memory...';
	window.status = 'Loading images into memory...';
	aImageSrc = preLoad(aFilNames,cPath);
} else {
	aImageSrc = AddPath(cPath, aFilNames);
}

// Create an instance of the images object.
oIMAGES1 = new ImgConst(aImageSrc,0);
//if (!msgWINDOW.closed) msgWINDOW.close();
OKAY = true;

iAvailW = parseInt(window.screen.availWidth);
iAvailH = parseInt(window.screen.availHeight);
iWidth = parseInt(window.innerWidth);
iHeight = parseInt(window.innerHeight);

/*
alert(" screen width = " + iAvailW + "\n screen height = " + iAvailH +
  "\n\n innerWidth = " + iWidth + "\n innerHeight = " + iHeight);
*/
//window.document.IMAGE01.width = iWidth;
//window.document.IMAGE01.height = iHeight;

} // endif

//defaultStatus = "";
window.status = "";

}


//- - - - - - - - - End IMAGE01 object - - - - - - - - -//

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);
}

// Image Functions //

function createNames(cPrefix,cSuffix,iStartnum,iEndnum,cExt) {
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 + cExt;
}
return aString;
}


function preLoad(aImgNames,cPath) {

var k = aImgNames.length;
var aImgSrc = new Array(k - 1);


if ( window.document.images ) { // Image swaps or rollovers can work.
	for ( var i = 0; i < k; i++ ) {
		aImgSrc[i] = new Image(); // Create a new image object
		// Set image object's src & forces download to browser's cache.
		aImgSrc[i].src = cPath + aImgNames[i];
	}
}
else {
	who("Image swaps or rollovers cannot work.");
}

return aImgSrc;

}


function accessImage(theImage) {

// Pass the image id that you are viewing.

alert(" Src = " + document.eval(theImage).src +
"\n Width  = " + document.eval(theImage).width  +
"\n Height = " + document.eval(theImage).height +
"\n Border = " + document.eval(theImage).border +
"\n Hspace = " + document.eval(theImage).hspace +
"\n Vspace = " + document.eval(theImage).vspace +
"\n TagName = " + document.eval(theImage).name +
"\n Complete = " + document.eval(theImage).complete +
"\n Lowsrc = " + document.eval(theImage).lowsrc +
"\n ProtoType = " + document.eval(theImage).prototype +
"\n OnError = " + document.eval(theImage).onerror +
"\n OnLoad = " + document.eval(theImage).onload +
"\n fileSize = " + document.eval(theImage).fileSize );
/*
border:  Integer that specifies the border width of the image, in pixels.
complete:  Boolean that specifies whether the image has loaded
completely: Successful or not.
fileSize:  Returns the file size of the specified image on the page.
	IE Windows, a numeric string is returned, while in
	IE Mac, a number instead.
	Use it on any image or a loop to cover all images on the page.
	IE only property.
height:  The height of the image.
hspace:  Reflects the "hspace" attribute.
lowsrc:  Reflects the "lowsrc" attribute.
name:	The name of the image as assigned by the "name" attribute.
src:	A read/write string specifying the URL of the image. Example(s).
vspace:  Reflects the "vspace" attribute.
width:  The width of the image.
onabort:  Code is executed when user aborts the downloading of the image.
onerror:  Code is executed when an error occurs with the loading of the
	image (ie: not found).
onload:  Code is executed when the image successfully and completely
	downloads.
*/

who();
return false;
}



// 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 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;
return 0;

}


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 initImages() {

OKAY = browserChk();	// Find out what browser this is.
if ( OKAY ){
	// Load names of images in array.
	aIMAGENAMES = createNames(cPrefix,cSuffix,iStartnum,iEndnum,cExt);
	// Load images into memory.
	aMYIMAGES = preLoad(aIMAGENAMES, cPath);
}
else {
	who();
}

}
//	Eof
