function showhideSecondLevel(id,currentElement) {
	var state = (document.getElementById(id).style.display=="" || document.getElementById(id).style.display=="none")?"none":"block";
	var noChildren = id.indexOf('sub_') == -1;
	// does this menu item exist, if not , do nothing
	if(document.getElementById(id)){
		//loop through for every second level
		for (var x = 1; x <= document.getElementsByTagName('div').length; x++) {
			//first hide all submenus
			var subMenuItem=document.getElementById('sub_' + x);
			if(subMenuItem){
				subMenuItem.style.display="none";
			}
		}
		// at this point all divs's are hidden
		// reshow the current one
		if(noChildren == false){
			// we are in a menu item that has children
			document.getElementById(id).style.display=(state == "block")?"none":"block";	
		}
	}
}

function showhideThirdLevel(id){
	if(document.getElementById(id)){
		var d = document.getElementById(id);
		//keep a record of display value before it gets set to none 
		var displayValue = d.style.display;
		//get the third level number, the id passed in will be like submenu2_2
		var posOfUnderscore=id.indexOf('_');
		var secondLevelNum = id.substr(7, posOfUnderscore-7);
		var thirdLevelID = document.getElementById('submenu' + secondLevelNum + '_'+i);
		//loop through the third level submenus and hide all
		for (var i = 1; thirdLevelID; i++) {
			thirdLevelID.style.display='none';	
		}
		d.style.display=(displayValue=='block')?'none':'block';
	}
}
function hideThirdLevel(){
	//loop through for every second level and hide any that may be showing
			for (var x = 1; document.getElementById('submenu' + x); x++) {
				for (var i = 1; document.getElementById('submenu' + x + '_'+ i); i++) {
					document.getElementById('submenu' + x + '_'+ i).style.display="none";
				}
			}
}
function toggleImage(id, currentElement){
		/*This syntax was used because getAttribute and setAttribute are not supported
		 in either Mac/IE5.0 or IE5.1 */
		 
		//keep a record of class value before it gets set to plus
		var classValue = currentElement.parentNode.className;
		var dtArray = document.getElementsByTagName('dt');
		//loop through all first level elements and set minuses to pluses
		for(var x=0; x < dtArray.length;x++){
			if(dtArray[x].className == "minus"){
				dtArray[x].className = "plus";
			}
		}
		if(classValue == "no"){
			//if there is no child elements don't change the image
			var newValue = classValue;
		}else{
			//if there is child elements change the image
			var newValue = (classValue == "plus" || classValue == null)?"minus":"plus";
		}
		currentElement.parentNode.className = newValue;
}

function makeCurrent(theElement){
	linklength = document.links.length;
	for(i=0;i<linklength;i++){
		if(document.links[i].className == 'current') {
			document.links[i].className = '';
		}
	}
	theElement.className = 'current';
}