/****** General Javascript Routines ******/



/****** Determine Browser version ******/

// Only bothers to recognise difference between Netscape 3 AND IE 4 and above and the rest //

var browName
var browVer
var brow
browName = navigator.appName;						// get browser name
browVer = parseInt(navigator.appVersion);			// and version
	if ((browName=="Netscape"&& browVer >= 3) ||
		(browName=="Microsoft Internet Explorer" && 
		browVer >=4)) brow = "n3";					// it's a browser version > IE 3
	else brow = "n2";								// no it's not


/****** Open a new window ******/


function openWin(URL,winnam,ht,wd,tp,lf) {
aWindow = window.open(URL,winnam,'height='+ht+',width='+wd+',top='+tp+',left='+lf+'');
}


/****** Put a new URL in 'opener' ******/

function go(url){
opener.location.href = url;
}

/****** Close this window ******/
function closewin(){
window.close()
}

/****** Switch to new pages in both Navigation and Main Frames ******/

function switchPages(toolURL,mainURL) {
parent.NavigationBar.location.href=toolURL;
parent.Homeframe.location.href=mainURL;
}

// Get browser type etc
//--------------------------------------------------------------------------
var browName
var browVer
var brow
browName = navigator.appName;						// get browser name
browVer = parseInt(navigator.appVersion);			// and version
	if ((browName=="Netscape"&& browVer >= 3) ||
		(browName=="Microsoft Internet Explorer" && 
		browVer >=4)) brow = "n3";					// it's a browser version > IE 3
	else brow = "n2";								// no it's not
//--------------------------------------------------------------------------

//****** Menuing system ******//
//
// This system relies on the DIV structure shown.....
// Class names must be AAAA9 where AAAA is 'menu' and 9 is 1 for the top level
// and is incremented for each sub-level.
// Sub-levels must have the same ID as the parent with the addition of the suffix 'sub'

//--------------------------------------------------------------------------
// Define and set some variables

var menLvl = 3;						// depth of menu items
var menAct = new Array(menLvl);		// ID's of 'active' items
var menVis = new Array(menLvl);		// ID's of 'visible' items
var basCol = new Array(menLvl);		// base colour for menu items
var ovrCol = new Array(menLvl);		// 'over' colour for menu items
var actCol = "red";					// active menu item colour
var clsNam = "";					// used to hold class name of element
var parLev = "";					// used to hold parent element when no class
var menLen = "";					// used to get length of class name
var menLev = ""; 					// used to get menu level (numeric value)
var menItem = "";					// holds ID of menu we're on

menAct[0] = "";						// 'active' item at each level
menAct[1] = "";
menAct[2] = "";

menVis[0] = "";						// 'visible' item at each level
menVis[1] = "";
menVis[2] = "";

basCol[0] = "blue";					// base colour of items at each level
basCol[1] = "lime";
basCol[2] = "#1F5176";

ovrCol[0] = "green";				// 'over' colour of items at each level
ovrCol[1] = "black";
ovrCol[2] = "fuchsia";

// Deal with mouse actions

//-------------------------------------------------------------------------
function mouseOver() {
getItem(ovrCol);					// set 'over' colour
}
//--------------------------------------------------------------------------
function mouseOut() {
getItem(basCol);					// set 'base' colour
}
//--------------------------------------------------------------------------
function mouseClick() {
menItem = event.srcElement.id;								// item we're over
if (menItem != "") {										// skip if no ID
if (document.all[menItem].style.color != actCol) {			// ignore if active element
	clsNam = document.all[menItem].className;				// get class
	if (clsNam == "") {										// got a class?
			 parLev = document.all[menItem].parentElement;	// no - get its parent
			 clsNam = document.all[parLev.id].className;		// parent's class
		}
		menLen = clsNam.length;
		menLev = clsNam.charAt(menLen-1);					// and level
	if (menAct[menLev-1] != "") {							// if same level item already active
		for (var i = menLvl-1; i > menLev-1; i--) {			// loop thru sub level pointers
			if (menVis[i] != "") {				
				document.all[menVis[i]].style.display = 'none';	// collapse any that are on view
				}
			if (menAct[i] != "") {
				document.all[menAct[i]].style.color = basCol[i];	// and set any active item
				}													// back to base colour
				menAct[i] = "";								// clear 'active' pointer
				menVis[i] = "";								// clear 'visible' pointer
		}
document.all[menAct[menLev-1]].style.color = basCol[menLev-1]; // and set higher level'off'
}
document.all[menItem].style.color = actCol					// set this item 'active'
menAct[menLev-1] = menItem									// and remember it
 	var mensub = document.all[[menItem + "sub"]];	
	if (mensub) {									// do we have a sub-menu?
		mensub.style.display = 'inline';					// yes - show it (doesn't seem to work
		menVis[menLev] = menItem + "sub";					// with Opera 5 which pretends to be IE4
		}
	}
	}
}
//---------------------------------------------------------------------------
function initMen() {										// initialise menu item colours
if (browVer > 3 && browName == "Microsoft Internet Explorer") {	// only use for IE4 etc for the moment						
for (var i = 0; i < document.all.length; i++) {				// loop thru' all elements
	clsNam = document.all(i).className;						// get Class name
	var menu = clsNam.substring(0,4);						// first 4 chars
	if (menu == "menu") {									// Menu?
		menLev = clsNam.charAt(4);							// Yes - get level
		document.all[i].style.color = basCol[menLev-1];		// and initialize colour
	}
}
document.all.home.style.color = actCol;						// set 'Home' to active colour
menAct[0] = 'home';											// and record it as active
}
else {

location.href = "Navigation.html";							// use old Navigation system for all
return true;												// others for the moment
}
}
//---------------------------------------------------------------------------
function getItem(setCol) {									// get menu item and set colour
menItem = event.srcElement.id;								// item we're over
if (menItem != "") {										// skip if no ID
if (document.all[menItem].style.color != actCol) {			// ignore if active element
	clsNam = document.all[menItem].className;				// get class
	if (clsNam == "") {										// got a class?
			 parLev = document.all[menItem].parentElement;	// no - get its parent
			 clsNam = document.all[parLev.id].className;		// parent's class
		}
		menLen = clsNam.length;
		menLev = clsNam.charAt(menLen-1);					// and level
		document.all[menItem].style.color = setCol[menLev-1];	// set colour	
		
		}
	}
}
//----------------------------------------------------------------------------
//-->


