// object oriented script to preload and swap images
// requires an onload statement in the body to preload images
// requires an event trigger somewhere in the page to start the action
var imgpath = 'media/';
var imgext = 'gif';
var imgloaded = false;
var suffix = new Array('on','off','onn');

function preloadimg()
{
	if(document.images)
	{
	var argsnum = arguments.length;
	for(var argcount = 0; argcount < argsnum; argcount++)
		{
		var imgid = arguments[argcount];
		var sufxnum = suffix.length;
		for(sufcount = 0;  sufcount < sufxnum; sufcount++)
			{
			var sufx = suffix[sufcount];
			imgnew = imgid + '_' + sufx + ' = new Image();'; eval(imgnew);
			imgsrc = imgid + '_' + sufx + '.src = \'' + imgpath + imgid + '_' + sufx + '.' + imgext +'\';'; eval(imgsrc);
			}
		}
	imgloaded = true;	
	}
}

// function to allow toggling between two versions of an img
toggle = true; 
function imgtoggle(imgid)
{
	if(document.images && imgloaded) {
		var imgstate = (toggle)?'off':'on';
		toggle = !toggle; 

		document.images[imgid].src = self[imgid + '_' + imgstate].src;
	}
}

// alter the visibility of the javascript warning, visible by default, use javascript to hide
function jswarn()
{
        if (document.getElementById) {  //Check in the W3C DOM is supported
        		var warn = document.getElementById('warning');
        		warn.style.visibility='hidden';
        }
        else if (document.all) {                //Check if the IE4 API is supported
                var warn = document.all['warning'];
                // warning.style.visibility is initially empty in IE5 until it is assigned 
                // so must check that it's not null before attempting change
                if ((warn.style) && 
                	(warn.style.visibility != null)) {
                        warn.style.visibility='hidden';
                }
        }
        else if (document.layers) {		//Check if the NS4 API is supported
				var warn = document.layers['warning'];
        		warn.visibility='hide';
		}
} 
