function swapImage () {
	var i, j = 0, x, a = swapImage.arguments;
	document.sr = new Array;
	for (i = 0; i < (a.length - 2); i += 3) {
		if ((x =findObj (a[i])) != null) {
			document.sr[j++] = x;
			if (!x.oSrc) x.oSrc = x.src;
			x.src = a[i + 2];
		}
	}
}

function swapImgRestore () {
	var i, x, a = document.sr;
	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function preloadImages () {
	var d = document; 
	if (d.images) {
		if (!d.p) d.p = new Array ();
		var i, j = d.p.length, a = preloadImages.arguments;
		for (i = 0; i < a.length; i++) {
			if (a[i].indexOf ("#") != 0) {
				d.p[j] = new Image;
				d.p[j++].src = a[i];
			}
		}
	}
}

/**
 * creates the onmouseover, onmouseout, onmouseup and onmousedown events to be used in butten-like images
 * images for button must be named like 'buttonname_on.gif', 'buttonname_over.gif', 'buttonname_down.gif'
 */
function createImageButton (img) {
	if (img) {
		img.onmouseover = function () { img.src = img.src.replace ('_on.gif', '_over.gif'); };
		img.onmouseout = function () { img.src = img.src.replace ('_over.gif', '_on.gif'); img.src = img.src.replace ('_down.gif', '_on.gif'); };
		img.onmousedown = function () { img.src = img.src.replace ('_over.gif', '_down.gif'); };
		img.onmouseup = function () { img.src= img.src.replace ('_down.gif', '_over.gif'); };
		preloadImages (img.src.replace ('_on.gif', '_over.gif'), img.src.replace ('_on.gif', '_down.gif'));
	}
}