function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

var newwindow;
function popup(url) { newwindow=window.open(url,"termswindow","width=600,height=400,top=200,left=200,scrollbars=yes,toolbar=no,menubar=no,resizable=yes");
if (window.focus) {newwindow.focus()}
}


function updatemenu()
{
	var fullURL =  window.location.href;
	var list  = document.getElementById("main-menu");
	if(list)
	{
		var listItems = list.getElementsByTagName("a");
		
		// match the subpages:
		if(fullURL.indexOf('glowworms.html')>1){
			listItems[1].parentNode.className = "selected"; return true;
		} else if(fullURL.indexOf('geology.html')>1){
			listItems[1].parentNode.className = "selected"; return true;
		} else if (fullURL.indexOf('caves.html')>1){
			listItems[1].parentNode.className = "selected"; return true;
		} else if(fullURL.indexOf('life-undergrowth.html')>1){
			listItems[1].parentNode.className = "selected"; return true;
		}
		// not a subpage so now find the item in the main menu.
		else
		{
			for(var j=0;j<=listItems.length-1; j++) 
			{
				if((listItems[j].href) == (fullURL))
				{
				 listItems[j].parentNode.className = "selected"; // select the li and write a class of selected on it
				}
			}
		}
	}
}

window.onload = function()
{
		updatemenu();
}

