
/*
 * This is the powerful script that makes image swapping more convenient
 * The Initial Developer of the Original Code is Leon S. Koshelev <leon_koshelev@yahoo.com>
 * Contributor(s): Andy V. Ivanov <iav@webmaster.spb.ru>
 * Version 2.4 27/12/2001 R1 20/10/2001
 * Visit http://www.web-master.spb.ru/free_lib/ for the latest version of this software.
 * Copyright (c) 2001 Leon S. Koshelev, Web-Master Co., Saint-Petersburg, Russia. All Rights Reserved.
 * This library is opensource software and distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
 * Permission to use, copy, modify, and distribute this software for any purposes and without fee is hereby granted provided that this copyright notice appears in all copies.
 */

//-----------------------------------------------------------------------

// This script will work in Navigator 3+, Explorer 4+, Opera 5+, etc.

//-----------------------------------------------------------------------

images=document.images;

//-----------------------------------------------------------------------

function imgSwapInit()
{
	arguments[0].imgRep=new Array();

	for(var i=1;i<arguments.length;i++)
	{
		arguments[0].imgRep[arguments[0].imgRep.length]=arguments[i];
	}

	arguments[0].onmouseover=imgOver;
	arguments[0].onmousedown=imgDown;
	arguments[0].onmouseout=imgOut;

	arguments[0].onmouseover();
}

function imgOver()
{
	for(var i=0;i<this.imgRep.length;i++)
	{
		with (this.imgRep[i])
		{
			if (complete && srcOver) src=srcOver.src;
		}
	}
}

function imgDown()
{
	for(var i=0;i<this.imgRep.length;i++)
	{
		with (this.imgRep[i])
		{
			if (complete && srcDown) src=srcDown.src;
		}
	}
}

function imgOut()
{
	for(var i=0;i<this.imgRep.length;i++)
	{
		with (this.imgRep[i])
		{
			if (complete && srcOut) src=srcOut.src;
		}
	}
}

function imgNew(URI)
{
	var o=new Image(); o.src=URI; return o;
}

function imgSrcAdd(obj)
{
	with(obj)
	{
		onload=srcDown=srcOver=srcOut=null;
	}

	if(arguments.length>2)
	{
		obj.srcDown=imgNew(arguments[2]);
	}
	if (arguments.length>1)
	{
		obj.srcOver=imgNew(arguments[1]);
		obj.srcOut=imgNew(obj.src);
	}
}
