startLinks = function() {
      var navRoot = document.getElementById("links");
        for (i=0; i<navRoot.childNodes.length; i++) {
        var node = navRoot.childNodes[i];
          if (node.className=="sublinks") {
            node.onclick=function() {
             var nodeUl = this.childNodes[3];
               if(nodeUl.style.display == "block"){
                    nodeUl.style.display = "none";
                }else{
                    nodeUl.style.display = "block";
                } 
            }
          }
        }
}
window.onload = startLinks;