var thisSection ="";
var end = 0;

function makeMenu() {
    
    var links = document.getElementsByTagName("li");

    for (var i=0; i < links.length; i++) {
        // Turn all items off
        if (links[i].className.match("section")) {
            //alert(links[i].childNodes[0].className);
            end = links[i].className.length;
            thisSection = links[i].className.substring(8, end);

            links[i].childNodes[0].onclick = Function("expand('" + thisSection + "')");
             
            links[i].childNodes[0].onkeypress = Function("expand('" + thisSection + "')");
  
         }
    }        
    

}

function expand(name) {

if (!document.getElementsByTagName) return false; // Can DOM ?

  var links = document.getElementsByTagName("li");

  for (var i=0; i < links.length; i++) {
        // Turn all items off
        if (links[i].className.match("item")) {
            links[i].style.display = "none"; 
        } else if (links[i].className.match("section")) {
            links[i].childNodes[0].style.background = "url('/images/interface/off.jpg') no-repeat";
        }   
        // Turn on selected items
        if (links[i].className.indexOf(name) > -1) {
            links[i].style.display = "block"; 
            if (links[i].className.match("section")) {
                links[i].childNodes[0].style.background = "url('/images/interface/on.jpg') no-repeat";
            }
            //var twoUp = oneUp.parentElement;
            //twoUp.style.background = "#ccc"
         }       
  }
}

window.onload=makeMenu;


