// The master lists of menu items.
var masterListMenu = new Array();
var masterListActuator = new Array();
var staticListActuator = new Array();

if (!document.getElementById) document.getElementById = function() { return null; }

function initializeStaticMenu(level, actuatorId) {

	initLevel(level);
		
	// Register NON-EXPANDING menu items with master list controller.
    staticListActuator[level][ staticListActuator[level].length] = actuatorId;
 }	
    
function initializeMenu(level, menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

	// actuator.parentNode.style.backgroundImage = "url(/images/plus.gif)";
	
	initLevel(level);
	
	// Register menu items with master list controller.
    masterListMenu[level][masterListMenu[level].length] = menuId;
    masterListActuator[level][masterListActuator[level].length] = actuatorId; 
    
    actuator.onclick = function() {       
		var display = menu.style.display;        
		// Turn off all the other registered menu items at current level.
		for (ii=0;ii<masterListActuator[level].length;ii++){
			var tempActuator = document.getElementById(masterListActuator[level][ii]);	       
		    
			if (tempActuator!=this){
				var tempMenu =  document.getElementById(masterListMenu[level][ii]);
				tempActuator.parentNode.style.backgroundImage =  "url(/images/plus.gif)";
	      		tempMenu.style.display = "none" ;
      		}	         
		}        
	     
		// Turn off all the other registered NON-EXPANDING menu items at current level.
		for (ii=0;ii<staticListActuator[level].length;ii++){
			var tempActuator = document.getElementById(staticListActuator[level][ii]);
		       
			if (tempActuator!=this){
				tempActuator.parentNode.style.backgroundImage =  "url(/images/clear.gif)";
			}	
		         
		}	
		    
		this.parentNode.style.backgroundImage = (display == "block") ? "url(/images/plus.gif)" : "url(/images/minus.gif)";
		menu.style.display = (display == "block") ? "none" : "block";
		return true; // false;
		}          
	}

function initLevel(curLevel){
	if ( staticListActuator[curLevel] == null) {
		 staticListActuator[curLevel] = new Array();
	} 
    
    if ( masterListMenu[curLevel] == null) {
		 masterListMenu[curLevel] = new Array();
	} 
	
	 if ( masterListActuator[curLevel] == null) {
		 masterListActuator[curLevel] = new Array();
	} 
}



	