/*******************************************************************************
*
*	Project		:	DBS General Library
*
*	File		:	DBS_ImageLib.js
*
*	Copyright	:	Data Broadcast Services Pty Ltd (DBS)
*					All rights reserved.
*
*	Purpose		:	Provide a library of functions to do with html images.
*
*					Each function may require a different version of JavaScript
*					in order to function correctly.  As a rule, these are
*					minimum versions.  These functions should be checked against 
*					any major release for deprecated / changed behaviour.
*
*					Highest version required:	JavaScript	1.1
*
*	Functions	:	
*					PreloadImages(...)
*
*	Version		:	A.0.1	11-Oct-2005
*
*	History		:	A.0.1	11-Oct-2005
*							CGHC
*							Created from scratch.
*
*******************************************************************************/


/*******************************************************************************
Globals
*******************************************************************************/
// This should be empty.  If not, find another way & make it empty


/*******************************************************************************
Functions
*******************************************************************************/
function included()
{
	alert("Included");
}


/*******************************************************************************
*
*	Function	:	PreloadImages()
*
*	Purpose		:	Preloads images in the background, should be called after the
*					page has loaded.
*
*	Parameters	:	...			Unknown number of urls of images, one per parameter,
*								the format of each matches that which can be used in
*								<IMG SRC=""> tags
*								NB: To comment out an image so it doesn't load, simply make its 
*									first char hash, ie '#'
*
*	Returns		:	boolean:	false	if successful  (allows for meaningful errors on failure)
*								true	otherwise
*
*	JavaScript	:	1.1
*
*	Assumptions	:	Can't really test for the validity of each parameter so user must ensure they're correct.
*
*	To Do List	:	
*
*******************************************************************************/

function PreloadImages()
{
	/*
	 * Variables
	 */
	var i;			// basic counter
	var j;			// basic counter
	var numArgs	= arguments.length;			// number of input images to preload
	if(!document.preloadImageArray)
	{
		// use a document var to ensure it keeps loading after function returns, ensure we don't splat any other preloads
		document.preloadImageArray	= new Array();
	}


	/*
	 * Go through list of arguments, loading each one that hasn't been commented out by '#' as the first character
	 */
	for(i=0, j=document.preloadImageArray.length; i < numArgs; i++)
	{
		if(arguments[i].indexOf("#") != 0)
		{
			document.preloadImageArray[j]	= new Image;
			document.preloadImageArray[j].src	= arguments[i];
			j++
		}
	}

	/*
	 * Tidy up & return
	 */
	return false;
}



function dbs_swap_image(xi_id, xi_image)
{
	document.getElementById(xi_id).src = xi_image;
}

