// created by Trevor Rawlings - please feel free add this code to your web site!
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
  if (navigator.appName == "Microsoft Internet Explorer") { isIE4 = true }else{ isIE4 = false}
  if(navigator.appName == "Netscape") { isNav4 =  true } else { isNav4 = false }
  var badBrowser = false
}else{var badBrowser = true}

var str="", Items, name, change, list, menu_load, str, cInd, image, i, ii, go, TT
Items = 50;
menu_load = false
window.onresize = resize;
text = new Array(Items)
text2 = new Array(Items)
indent = new Array(Items + 1)  
name = new Array(Items + 1)
visable = new Array(Items+1)
var relPos = ""     //can be set on each calling page to take account of the fact than not all pages are in the same directory (e.g. add the code relPos="..\..\" the page that has called this file)
i=1

function newItem(Indents, Name, Html) {
text[i] = Html
indent[i] = Indents
name[i] = Name
// visable[i] = false
i=i+1
Items = i
}

function menuload() {
menustyle()
for(var i = 1; i < Items; i++) { if (indent[i] == 1)  visable[i] = true  }
for(var i = 1; i < Items; i++) { 
  text2[i] = ""
  if (indent[i] == 2) text2[i] = "&nbsp;&nbsp;&nbsp;&nbsp;"
  if (indent[i] == 3) text2[i] = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
}
menu_load = true
redraw()
}

function openMenu_at(){ var T
Name = document.title
for( T =1; T < Items; T++) { if (name[T] == Name) TT=T }
// while (indent[TT-1] >= indent[TT]) {TT = TT-1}
itemClicked(TT-1)
}

function itemClicked(i) {
self.status ="updating list"
if (visable[i+1] == true) {change = false}else{change=true}
for (T=1; T<Items; T++) {if (indent[T] > 1) visable[T] = false}  //closing every thing other than 1's
if (change==true) { openBranch(i+1) }else{
if (indent[i] > 1) { while (indent[i-1] >= indent[i]) { i = i-1} 
openBranch(i)}}
redraw() 
self.status}

function openBranch(i) {
while (indent[i]>1) {
cInd=indent[i]
while (indent[i-1]>=cInd) {i=i-1}
expand(i); i=i-1 }
}
	
function expand(a) {
indAtStart=indent[a]
while (indent[a] >= indAtStart ){  if (indent[a] == indAtStart) visable[a] = true 
a = a + 1 }
}

function expand2(i){if (isNav4) itemClicked(i)}

function resize() {
 if (menu_load == true){
window.history.go(0);
redraw()    
 }
}

function menu(){
if (badBrowser){ alert ("some elements of this page require a version 4 browser"); return;}
if (menu_load == false) menuload()
if (list==true) {
     hideMenu()
   }else{
     showMenu()
    }
}

function hideMenu() {
     if(isNav4) {
	container.visibility = "hide";
	document.a.src = relPos+"icon.gif"
     } else {
	myDiv.style.visibility = "hidden"
	a.src = relPos+"icon.gif"
     }
     list=false
}
function showMenu() {
    if(isNav4){
	container.visibility = "show";
	document.a.src = relPos+"icon2.gif"
    }else{
	myDiv.style.visibility = "visible"
	a.src = relPos+"icon2.gif"
    }
    list=true
}



