/*
Script for simple image swap and restore
Requires getElementById (native or emulated)
*/

var IMAGESWAP_JS = true;

var swaplist=new Array();

function copy_root(oldfn, newfn)
{
	var root = oldfn.match(/.+[\/]/);
	return root+newfn;
}

function swap(id, newsrc, same_root)
{
	if (document.getElementById) {
		var img = typeof(id)=='string'?document.getElementById(id):id;

		newsrc = same_root ? copy_root(img.src, newsrc) : newsrc;
		swaplist[id] = img.src;
		img.src = newsrc;
	}
}

function unswap(id)
{
	if (document.getElementById) {
		var img = typeof(id)=='string'?document.getElementById(id):id;
		img.src = swaplist[id];
	}
}
