/*	Copyright (c) 1996,2001 Picdar Technology Limited       All Rights Reserved
 *
 * 	This is UNPUBLISHED PROPRIETARY work of Picdar Technology Limited;
 * 	the contents of this file may not be disclosed to third parties, copied or
 * 	duplicated in any form, in whole or in part, without the prior written
 * 	permission of Picdar Technology Limited
 *
 *	Module   :	Images001.js
 *
 *	Synopsis :	Script library for Image-related JS functions.
 *
 *	Author   :	Adam Creeger
 *
 */

/* This function is used in the onload hander of the body tag. It is designed to be used
	with the TCL common code functions Javascript::ImageCycleInit and Javascript::ImageCycleTag.
	the arguments are:
		theID: a string containing the ID of the ImageCycle. This should be the same as the id used with
				the javascript common code functions above.
				
		interval: the length of time, in milliseconds, that each image is displayed for. (1000ms = 1s)
*/
function StartImageCycle(theID,interval)
	{
	idString = '_' + theID + '_';
	eval('locArray = ' + idString + 'Array');
	eval('locURLArray = ' + idString + 'URLArray'); 
	for (var counter = 0; counter < locURLArray.length; counter++)
		{
		locArray[counter] = new Image();
		locArray[counter].src = locURLArray[counter];
		}
	eval(idString + 'Array = locArray');
	eval("setInterval(\"_ImageCycle(\'" + theID + "\');\"," + interval + ")");
	}

/* This is an internal function used to cycle the images.
*/
function _ImageCycle(id)
	{
	var idString = '_' + id + '_';
	eval('locCurrentImage = ' + idString + 'CurrentImage');
	eval('locArray = '+ idString + 'Array');
	if (locCurrentImage == locArray.length - 1)
		{
		eval(idString + 'CurrentImage = 0');
		locCurrentImage = 0;
		}
	else
		{
		eval(idString + 'CurrentImage++');
		locCurrentImage++;
		}
	self.document.images['IMG'+idString].src = locArray[locCurrentImage].src;
	}
	
	/* This function is to be used with the "onMouseOver" event handler. For it to work there must be an 
   image defined as "<strImage>Out". For example the code:
   
	   var loginOver = new image();
	   loginOver.src = "/images/imageA.gif"
   
	would enable this function to work.
	
	The first line of the above code should be outside of any functions so that the variable 
	is global.
	The second line could be in a preLoadImages() function that is used with the 
	"onLoad" handler of the BODY tag. Using this method, there is no delay in the replacement
	of images.
	
	The string passed as the image name needs to be the same as the "name" attribute in the
	appropritate IMG tag. (note: this is case sensitive). For example in the above case the name
	attribute of the IMG tag would be "login".
*/ 

function SwapImageOver(strImage)
    {
    with (document.images[strImage])
    	{
    	src = eval(strImage + "Over.src");
    	}
    }

/* This function is to be used with the "onMouseOut" event handler. For it to work there must be an 
   image defined as "<strImage>Out". For example the code:
   
	   var loginOut = new image();
	   loginOut.src = "/images/imageB.gif"
   
	would enable this function to work. 
	
	The first line of the above code should be outside of any functions so that the variable 
	is global.
	The second line could be in a preLoadImages() function that is used with the 
	"onLoad" handler of the BODY tag. Using this method, there is no delay in the replacement
	of images.
	
	The string passed as the image name needs to be the same as the "name" attribute in the
	appropritate IMG tag. (note: this is case sensitive). For example in the above case the name
	attribute of the IMG tag would be "login".
*/ 
function SwapImageOut(strImage)
    {
    with (document.images[strImage])
    	{
    	src = eval(strImage + "Out.src");
    	}
    }
   

/* This function is used to swap the image in "strDestination" with the image stored using "strImage". 
	For it to work there must be an image defined as "<strImage>". For example the code:
   
	   var usrMgmt = new image();
	   usrMgmt.src = "/images/image.gif"
   
	would enable this function to work. 
	
	The first line of the above code should be outside of any functions so that the variable 
	is global.
	The second line could be in a preLoadImages() function that is used with the 
	"onLoad" handler of the BODY tag. Using this method, there is no delay in the replacement
	of images.
	
	"strDestination" needs to be the same as the "name" attribute in the
	appropritate IMG tag. (note: this is case sensitive).
*/
function SwapImage(strDestination,strImage)
	{
	with (document.images[strDestination])
		{
		src = eval(strImage + ".src");
		}
	}
	
