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 changeClass(objectName,newClass)
	{
	var o=getObj(objectName);
	o.className=newClass;
	}

	
function changeImageSource(imageName,imageSource)
	{
	var fullName="window.document."+imageName;
	fullName.src="./images/blank.gif";
	}
	
		
function changeVisibleImage(imageIDprefix,imageToDisplayIDsuffix,imageIDmaxSuffix)
	{
	//this function presumes that all image IDs are created from a standard prefix followed by a numeric suffix
	//for example - imageArray-0
	//this presumes that all rollovers are created from overlaid images rather than changing the src definition
	//this has time benefits, in some browsers, over the more usual system of preloading images
	var img="";
	for (i=1;i<(imageIDmaxSuffix+1);i++)
		{
		img=getObj(imageIDprefix+i);
		(imageToDisplayIDsuffix==i)?img.style.visibility="visible" : img.style.visibility="hidden" ;
		}
	}


//BUTTON HIGHLIGHTING AND UNHIGHLIGHTING FUNCTIONS//
//
//
//the functions and variables below are for use with buttons and groups of buttons
//
//button IDs should be created according to the following pattern
//     buttonSeries + buttonNumber + imageNumber
//          buttonSeries - if there are ten buttons, for example, each one of which can be highlighted or not
//          buttonNumber - the number of each individual button within the series
//          imageNumber - '1' = unhighlighted image : '2' = highlighted image 
//     example: menuButtons11
//
//tempHighlight/tempHighlightOff functions:-
//
//     tempHighlight function takes as its single argument buttonSeries+buttonNumber
//     It also uses the global variable 'button' to record the value of their single argument.
//     This means that tempHighlightOff needs no argument, taking the required information from the global variable 'button'.
//     They use the global variable 'highlighted' to record/restore the original state of the button in question.
//     
//
//highlight functions:-
//     This function takes three arguments, buttonSeries (see above), buttonNumber (see above) and maxButtons,
//     which defines the maximum number of buttons in the series. It addresses the global variable 'highlighted'
//
//N.B. Any button which is to be initially highlighted must have its highlighted image visibility explicitly set to "visible".

var highlighted=false;
var button="aa";

function tempHighlight(imageIDprefix)
	{
	var img='';
	//checking previous state of highlighted image - if visible, button was highlighted
		img=getObj(imageIDprefix+'2');
		(img.style.visibility=="visible")? highlighted=true : highlighted=false;
	//set the global variable 'button'
	button=imageIDprefix;

	//no point in highlighting the image if it is already highlighted
	if (highlighted==false)
		{
		img=getObj(imageIDprefix+'2');
		img.style.visibility="visible";
		img=getObj(imageIDprefix+'1');
		img.style.visibility="hidden";
		}
	}

function tempHighlightOff()
	{
	//do not wish to take highlighting off a button which is meant to be highlighted	
	if (highlighted==false)
		{
		var img=getObj(button+'1');
		img.style.visibility="visible";
		img=getObj(button+'2');
		img.style.visibility="hidden";
		}
	}

function highlight(buttonSeries,buttonNumber,maxButtons)
	{
	var img;
	var buttonName='';
	for (i=1;i<=maxButtons;i++)
		{
		buttonName=buttonSeries+i+'1';
		img=getObj(buttonName);
		(i==buttonNumber)?img.style.visibility="hidden":img.style.visibility="visible";
		buttonName=buttonSeries+i+'2';
		img=getObj(buttonName);
		(i==buttonNumber)?img.style.visibility="visible":img.style.visibility="hidden";
		}
	highlighted=true;
	}

	
//END BUTTON HIGHLIGHTING AND UNHIGHLIGHTING FUNCTIONS//

