// Copyright info://// This JavaScript code is © Copyright, December 1998, by Black Type White Paper// All rights reserved unless explicitly given written permission// This code is permitted for use by Black Type White Paper customers only// Do not change this code in any way, Black Type White Paper will not be// responsible for any changes to this specific file by the customer//// Release Version: 2.3.2// // Internal Version bug fix history://		//		2.1.4:	Initial tracking release////		2.1.5:	fixed attempt at displaying of non-existant state in iDisplayNow()////		2.2.5:	Added in much more comprehensive debugging display routines////		2.2.6:	fixed incorrect image drawing in iDisplayNow(),//					was trying to display an IMG rather than a Cached Image (which is linked to an IMG) [doh!]//					removed redundant calls to series linking detection, a featuritis that never worked//					fixed erroneous call in iDisplayLater, changed call from iDisplayNow() to DisplayNow()////		2.2.7:	Doh!#2   Discovered that Netscape evaluates the following statement "incorrectly":////						if (!theState)//							theState = 1;////					If theState is defined as the number zero, then the IF statement evaluates as true,//					yet in our calls the zero value is valid. IE seems to handle this better by//					evaluating !theState as the existence of a variable.////		2.2.8:	Fixed PC runtime issues with calling DisplayXXX() routines//					Thanks Microsoft, your multi-threading sux (same problem with both Netscape and IE//					so it has to be a multi-threading issue, and not a browser issue.)////		2.3.0:	Added the ability to "select" a cached image.////		2.3.1		In the interest of space saving the following features have been dropped//					1) AnimatedOnce GIFs//					2) Linking to a frame//					3) Debugging support//					This drops the file size from 8900 bytes (after optimatization of names//					down to less than 1/2 of that original size////		2.3.2		Clarified the "selection" of an image. Now, when an image is selected,//					the "off" (mouseout) and "on" (mouseover) states are set to the "selected"//					state.////					Added the function SelectState() which outdates the now removed functions//					SelectOnState() and SelectOffState()////					Removed another piece of Frame related code, saved another 200 bytes or soCaching					= new Object();// Defaults for caching, user can change these with the accessor functionsCaching.Default		= new Object();Default					= Caching.Default;		// Default is a shortcut variableDefault.ImagePath		= "art";						// Accessor Function: DefaultImagePath()Default.ImageExte		= "jpg";						// Accessor Function: DefaultImageExtension()Default.ErrorLimit	= 5;							// Accessor Function: DefaultErrorLimit()Caching.Loading		= true;Caching.Cache			= "top.zCache";			// "top." is used to preserve caching across framesCaching.Images			= "Caching.zImages";		// Name space for image associationsCaching.Series			= "Caching.zSeries";		// Name space for recording Series names and their detailsCaching.Errors			= "Caching.zErrors";		// Name space for keeping track of Displayxxx() call errors if (!this[Caching.Cache])							// does the cache database exist?	this[Caching.Cache]	= new Object();		// no, create itthis[Caching.Images]		= new Object();this[Caching.Series]		= new Object();	Caching.Cache		+= ".";							// From now on, only the names within each objectCaching.Images		+= ".";							// will be used, and not the object itself. So we addCaching.Series		+= ".";							// in the member selector "." to make the following codeCaching.Errors		+= ".";function AssociateImageToIMGs(theImage, theIMG, theFrom, theTo){	for (var i = theFrom; i <= theTo; i++)		this[Caching.Images + theIMG + i] = theImage;}function AssociateIMGToSeries(theIMG, theSeries){	var Series = this[Caching.Series + theSeries];		if (Series)		for (var i = Series.From; i <= Series.To; i++)			this[Caching.Images + theSeries + i] = theIMG;	else		document.write("Internal Error: AssociateImageToSeries().. the series: '"+theSeries+"' is not cached");}function CacheSeries(theSeries, theFrom, theTo, theState1, theState2, theState3, theState4){	if (!theState1)		theState1 = "";	iCacheSeries(theSeries, theFrom, theTo, theState1);	if (theState2)	iCacheSeries(theSeries, theFrom, theTo, theState2);	if (theState3)	iCacheSeries(theSeries, theFrom, theTo, theState3);	if (theState4)	iCacheSeries(theSeries, theFrom, theTo, theState4);}function iCacheSeries(theSeries, theFrom, theTo, theStateFile){	var NaE			= theSeries.split('.');			// separate the name from the extension	var StateNaE	= theStateFile.split('.');		// ditto		if (!StateNaE[1])										// if no extension given in state,		StateNaE[1] = Default.ImageExte;				// give it our default	if (!NaE[1])											// if no extension given in series,		NaE[1] = StateNaE[1];							// set it to the state's extension	var Series = iFindOrCreateSeries(Caching.Series+NaE[0], theFrom, theTo);	for (var i = theFrom; i <= theTo; i++)		iCacheFile(Series, NaE[0] + i + '.' + NaE[1], StateNaE[0]);}function iFindOrCreateSeries(theName, theFrom, theTo){	var SeriesName = Caching.Series + theName;	var Series = this[SeriesName];		if (!Series)	{		Series				= new Object();		Series.From			= theFrom;		Series.To			= theTo;		Series.Selected	= "";		this[SeriesName]	= Series;	} else	{		if (theFrom < Series.From)		Series.From = theFrom;	// make sure our beginning range is correct		if (theTo > Series.To)			Series.To = theTo;		// make sure our end range is correct	}	return Series;}function DupImage(theSeriesName, theNewImage, theOldImage){	var OiC = this[Caching.Cache + theOldImage];	if (OiC)	{		var OtC = new Object;				OtC.Props = new Array();		for (var i=0; i<=OiC.Props.length-1; i++)		{			OtC.Props[i].Cache = new Image();			OtC.Props[i].Cache.src = OiC.Props[i].Cache.src			OtC.Props[i].Image = OtC.Props[i].Cache;			OtC.Series = theSeriesName;		}		this[Caching.Cache + theNewImage] = OtC;						// make the Cached image available to the Caching interface	}}function DupSeries(theNewSeriesName, theNewFrom, theNewTo, theOldSeriesName, theOldFrom, theOldTo){	var	Series = iFindOrCreateSeries(theNewSeriesName);	var	curOld = theOldFrom;	for (var i=theNewFrom; i<=theNewTo; i++, curOld++)	{		if (curOld > theOldTo)			curOld = theOldFrom;				DupImage(theNewSeriesName, theNewSeries+i, theOldSeriesName+curOld);	}	}function iCacheFile(theSeries, theFile, theState)				// Requires an extension in the file name{	if (!theState)		theState = "";	if (theFile)	{			var NaE				= theFile.split('.');					// NaE means "Name and Extension"		var OtCName			= Caching.Cache + NaE[0];		var OtC				= this[OtCName];							// OtC means "Object to Cache"				if (!OtC)															// if the series doesn't exist		{																		// then build a new series			OtC				= new Object();			OtC.Props		= new Array();			this[OtCName]	= OtC;		}		var Props = new Object();		Props.Cache = new Image();		Props.Image = Props.Cache;		Props.Cache.src	= Default.ImagePath+"/"+NaE[0]+theState+'.'+NaE[1];				OtC.Props[OtC.Props.length]	= Props;		OtC.Series = theSeries;	}}function iDisplayNow(theIMG, theImage, theState){	var OiC = this[Caching.Cache + theImage];						// OiC = Object in Cache	if (OiC)	{		if (OiC.Props.length <= theState)			theState = OiC.Props.length-1;		document.images[theIMG].src = OiC.Props[theState].Image.src;	}}function iDisplayState(theImage, theState){	var Displayed = false;		if(document.images[theImage])	{		iDisplayNow(theImage, theImage, theState);		Displayed = true;	}	var Associate = this[Caching.Images + theImage];	if (Associate)	{		if (document.images[Associate])		{			iDisplayNow(Associate, theImage, theState);			Displayed = true;		}	}		if (!Displayed)	{		var Error = this[Caching.Errors + theImage];		if (Error)	Error += 1;		else			Error = 1;				if (Error > Caching.Default.ErrorLimit)			document.write("Internal Error: iDisplayState().. '"+theImage+"' does not exist in images[] nor is it cached");	}}function Display(theImage)						{	DisplayState(theImage, 0);	}function DisplayOff(theImage)					{	DisplayNow(theImage, 0);	}function DisplayOn(theImage)					{	DisplayNow(theImage, 1);	}function iFindOrCreateSeries(theSeriesName, theFrom, theTo){	var SeriesName = Caching.Series + theSeriesName;	var Series = this[SeriesName];		if (!Series)	{		Series				= new Object();		Series.From			= theFrom;		Series.To			= theTo;		Series.Selected	= "";		this[SeriesName]	= Series;	} else	{		if (theFrom < Series.From)		Series.From = theFrom;	// make sure our beginning range is correct		if (theTo > Series.To)			Series.To = theTo;		// make sure our end range is correct	}	return Series;}function DupImage(theSeries, theNewImage, theOldImage){	var OiC = this[Caching.Cache + theOldImage];	if (OiC)	{		var OtC = new Object;		OtC.Props = new Array(OiC.Props.length);		for (var i=0; i<OiC.Props.length; i++)		{			OtC.Props[i] = new Object;			OtC.Props[i].Cache = new Image();			OtC.Props[i].Cache.src = OiC.Props[i].Cache.src			OtC.Props[i].Image = OtC.Props[i].Cache;			OtC.Series = theSeries;		}		this[Caching.Cache + theNewImage] = OtC;					// make the Cached image available to the Caching interface	}}function DupSeries(theNewSeriesName, theNewFrom, theNewTo, theOldSeriesName, theOldFrom, theOldTo){	var	Series = iFindOrCreateSeries(theNewSeriesName, theNewFrom, theNewTo);	var	curOld = theOldFrom;	for (var i=theNewFrom; i<=theNewTo; i++, curOld++)	{		if (curOld > theOldTo)			curOld = theOldFrom;				DupImage(Series, theNewSeriesName+i, theOldSeriesName+curOld);	}}function RandomNumber(theUpperLimit){	var now = new Date();	var rand = Math.round(theUpperLimit * Math.cos(now.getTime()));	if (rand < 0) rand = - rand; if (rand == 0) rand++;		return rand;}function iSelect(theImage, theCachedState){	var OiC = this[Caching.Cache + theImage];		if (OiC)	{		if (OiC.Series.Selected != "")		{			ResetStates(OiC.Series.Selected);			DisplayOff(OiC.Series.Selected);		}		OiC.Series.Selected = theImage;				SetState(theImage, 0, theCachedState);		SetState(theImage, 1, theCachedState);		DisplayOn(theImage);	}}function SetState(theImage, theDesiredState, theCachedState){	var OiC = this[Caching.Cache + theImage];	if (OiC)		OiC.Props[theDesiredState].Image = OiC.Props[theCachedState].Cache;	}function ResetStates(theImage){	var OiC = this[Caching.Cache + theImage];	if (OiC)		for (var i = 0; i <= OiC.Props.length-1; i++)			OiC.Props[i].Image = OiC.Props[i].Cache;}function SelectState(theImage, theState)	{	iSelect(theImage, theState);	}function SelectOn(theImage)					{	SelectState(theImage, 1);		}function SelectOff(theImage)					{	SelectState(theImage, 0);		}function DisplayNow(theImage, theState)	{	iDisplayState(theImage, theState);	}function DisplayState(theImage, theState)	{	iDisplayState(theImage, theState);	}function CacheCleanup()							{	Caching.Loading = false;			}function DefaultImagePath(thePath)			{	Default.ImagePath = thePath;		}function DefaultImageExtension(theExte)	{	Default.ImageExte = theExte;		}function DefaultErrorLimit(theLimit)		{	Default.ErrorLimit = theLimit;	}