function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

	
function getObj(name)
	{
	if 		(document.getElementById) 		var o=document.getElementById(name);
	else if 	(document.all) 				var o=document.all(name);
	else if 	(document.layers) 			var o=getObjNN4(document,name);

	return o
	}

	
function getNum(str)
	{
	//extract a number from a variable with a mixed value, e.g. returns of obj.style.width
	var num="";
	
	if (isNaN(str))
		{
		for (i=0;i<str.length;i++) if (!isNaN(str.charAt(i))) num=num+""+str.charAt(i);	
		}
	else num=str;

	return eval(num);
	}

		
function changeVisibleImage(imageIDprefix,imageToDisplayIDsuffix,imageIDmaxSuffix)
	{
	/*
	This function presumes that there is a collection of images, one upon the other, with each image bearing
	an ID consisting of an imageIDprefix and a number - e.g. "imageArray-" and 0.
	The arguments to this function define the imageIDprefix, as well as the number of the image which it is 
	desired to be displayed, as well as the total number of images.
	The numbering is presumed to start from 0.
	*/
	var img="";
	for (i=1;i<=imageIDmaxSuffix;i++)
		{
		img=getObj(imageIDprefix+i);
		(imageToDisplayIDsuffix==i)? img.style.visibility="visible": img.style.visibility="hidden";
		}
	}

function changeClass(objectName,newClass)
	{
	var o=getObj(objectName);
	o.className=newClass;
	}
	
function changeImageSource(imageName,imageSource)
	{
	var fullName="window.document."+imageName;
	fullName.src=imageSource;
	}

var button="aa";
var highlighted=true;
var thumbnailGroupOn=1;

function tempHighlight(imageIDprefix)
	{
	/*This function presumes:
		that what is to be highlighted is a <div> containing two images, one overlaid upon the other
		the images each have an ID formed from an imageIDprefix and a number, either 1 or 2
		with 1 being the standard image, and 2 the highlighted one.
		
	This function depends upon the global variables "button".
	
	This function works by setting the value of the global variable "button" to the argument imageIDprfix.
	Following this, the image with the ID of imageIDprefix+1 is set to hidden, whilst the other image is
	set to visible.
	
	The complementary function TempHIghlightOff() uses the information in "button" to supply the primary part
	of the image names, adding "1" and "2' to complete the names. It sets the image "button"+1 to visible and
	"button"+2 to hidden.
	
	Where one pair of images is representing the currently selected option, both images have the src set to 
	the highlighted form of the image.
	*/
	var img='';
	button=imageIDprefix;
	img=getObj(imageIDprefix+'2');
	img.style.visibility="visible";
	img=getObj(imageIDprefix+'1');
	img.style.visibility="hidden";
		
	}

function tempHighlightOff()
	{
	var img=getObj(button+'1');
	img.style.visibility="visible";
	img=getObj(button+'2');
	img.style.visibility="hidden";
	}

function setCurrentOption(currentOption)
	{
	/*
	This function presumes:
		.a series of options, each of which bears two images, one overlaid upon the other.
		.the names of the images are made up of "currentOption" and a number "1" (standard) or "2" (highlighted)
	
	When an option is set as current, the image indicating unselected has its source changed to that of the image
	which is indicating selected.
	
	Thus, when tempHighlight() is used, there appears to be no change.
	*/
	var standardImageName=currentOption+"1";
	var highlightedImageName=currentOption+"2";
	document[standardImageName].src=document[highlightedImageName].src;
	}
	
	
var thumbnailGroupOn=1;
var thumbnailsPerGroup=4;
var thumbnailGroupsMax=3;

function changeThumbnails()
	{

	(thumbnailGroupOn==thumbnailGroupsMax)?thumbnailGroupOn=1:thumbnailGroupOn++;
	minOn=((thumbnailGroupOn*thumbnailsPerGroup)-(thumbnailsPerGroup-1));
	maxOn=(thumbnailGroupOn*thumbnailsPerGroup);

	var thumbnail='';
	var img="";
	
	for (i=1;i<=(thumbnailsPerGroup*thumbnailGroupsMax);i++)
		{
		thumbnail="thumb"+i+"1";
		img=getObj(thumbnail);
		(i<minOn||i>maxOn)?img.style.visibility="hidden":img.style.visibility="visible";
		}
	}
