// this part from Carr for internal navigation
window.onload = function() {
initializeMenu("menu01", "actuator01");
initializeMenu("menu02", "actuator02");
initializeMenu("menu03", "actuator03");
initializeMenu("menu04", "actuator04");
}


//adapted from http://support.internetconnection.net/CODE_LIBRARY/Javascript_Show_Hide.shtml

//here you place the ids of every element you want.
//var ids=new Array('sect01','sect02');

var ids = new Array();
var lis = new Array();
var alldivs  = document.getElementsByTagName("div");
var alllis   = document.getElementsByTagName("a");
	
	
function makelisarray() {
	for (var i=0;i<alllis.length;i++){
		if (alllis[i].className == "MenuLink") {
			lis.push(alllis[i].id);
			//document.write(alllis[i].id);
			} // end if class=MenuLink
	} // for i<alllis.length			
} // end function makelisarray

	
function makeidsarray() {
	for (var i=0;i<alldivs.length;i++){
		if (alldivs[i].className == "PageSection") {
			ids.push(alldivs[i].id);
			//document.write(alldivs[i].id);
			} // end if class=PageSection
	} // for i<alldivs.length			
} // end function makeidsarray
 

function switchid(id,li){	
	if (id == 'sectALL') {
		hideallids(); // hide section divs AND reset menu background color 	  
		showalldivs();
	} else {
		hideallids(); // hide section divs AND reset menu background color
		showdiv(id);
		setcurrentmenucolor(li); // set the selected menu item background color
	}
	
} // end function switchid

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
//	console.log("The value of lis.length is %s", lis.length) ;
	for (var i=0;i<lis.length;i++){
		resetbackground(lis[i]);
	}		

	
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id

	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	} // end if dom3 
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		 }
		else { // IE 4
			document.all.id.style.display = 'block';
		 }
	} // end else not dom 3 
 } // end function showdiv

function resetbackground(id) {
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.backgroundColor = '#D6DBB1'; 
//		document.getElementById(id).style.background = 'url(/images/rightbackground.gif)';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.bgColor = '#D6DBB1'; // not sure on setting image on this one, leaving color
		}
		else { // IE 4
//			document.all.id.style.background = 'url(/images/rightbackground.gif)';
			document.all.li.style.backgroundColor = '#D6DBB1' ;
		}
	}
}
 
function setcurrentmenucolor(li) {
 if (li) {  // if one passed in to set menu color
	
	if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(li).style.backgroundColor = '#ffffff' ;
	}
	else { // not dom3
		if (document.layers) { // Netscape 4
			document.li.bgColor = '#ffffff';  
		}
		else { // IE 4
			document.all.li.style.backgroundColor = '#ffffff' ;
		}
	} // end else not dom3
 } // end if id
} // end function setcurrentmenucolor

function showalldivs() {
	//safe function to hide an element with a specified id
	
	for (var i=0;i<ids.length;i++){
		if (ids[i] == "sect01"  || ids[i] == "sect99" ) { // don't display intro nor classes section
			if (document.getElementById) { // DOM3 = IE5, NS6
				document.getElementById(ids[i]).style.display = 'none';
				}
			else { // is not dom3
				if (document.layers) { // Netscape 4
					document.ids[i].display = 'none';
					}
			else { // IE 4
			document.all.ids[i].style.display = 'none';
				} // end else IE5
			}// end else is not dom3
			
			
		} else {	// is section to display	
			if (document.getElementById) { // DOM3 = IE5, NS6
				document.getElementById(ids[i]).style.display = 'block';
				}
			else { // is not dom3
				if (document.layers) { // Netscape 4
					document.ids[i].display = 'block';
					}
			else { // IE 4
			document.all.ids[i].style.display = 'block';
				} // end else IE5
			}// end else is not dom3
 		} // else is a section to display
	} // for i<ids.length	

} // end showalldivs

