//This script is extracted from showhide.js from www.grainge.org
//showhide.js was originally written by Greg Swearingen in January 2004 when the
//previous method was found not to work in later versions of RH.
//It was then found that the new script was not compatible with RH X4 or later.
//Paul Symonds of Cedar Software then rewrote part of it in March 2004 to make it
//work with RH X4 and remain compatible with earlier versions (only tested in X3.
//Peter Grainge 050304


function replaceSubstring(inputString, fromString, toString) 
{
   
	// Goes through the inputString and replaces every occurrence of fromString with toString
	var temp = inputString;
	
	if (fromString == "") 
	{
		return inputString;
	}
	
	if (toString.indexOf(fromString) == -1) 
	{ 
		while (temp.indexOf(fromString) != -1) 
		{
			 var toTheLeft = temp.substring(0, temp.indexOf(fromString));
			 var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
			 temp = toTheLeft + toString + toTheRight;
		}
	}
	
		
	// Send the updated string back to the user
	return temp; 
} 


function swapImages(imageName) 
{

	matchpattern = /ddminus.gif/;
	if (matchpattern.test(imageName.src)) 
	{
		//Replace image name leaving path intact
		newName = replaceSubstring(imageName.src, "ddminus.gif", "ddplus.gif") 
		 
		document.images[imageName.name].src=newName;
	}
	else 
	{       //Replace image name leaving path intact
		newName = replaceSubstring(imageName.src, "ddplus.gif", "ddminus.gif" ) 
		 
		document.images[imageName.name].src=newName;
	}
}
