Dear All,
I have a javascript as below. My problem is that span.onclick I have tried to run a for loop and set all the ul.style.display to none but it all disappear. What I want to achieve is that if one of the tree plus button is click I want all the rest to be closed?


PHP Code:
this.sitemapstyler = function(){
    var 
sitemap document.getElementById("sitemap")
    if(
sitemap){
        
        
this.listItem = function(li){
            if(
li.getElementsByTagName("ul").length 0){
                var 
ul li.getElementsByTagName("ul")[0];
                
//alert("NAme is :"+ul);
                
ul.style.display "none";
                var 
span document.createElement("span");
                
span.className "collapsed";
                
span.onclick = function(){
                    
                    
                    
                    
//alert("ul.style.display :"+ul.style.display );
                    
ul.style.display = (ul.style.display == "none") ? "block" "none";
                    
this.className = (ul.style.display == "none") ? "collapsed" "expanded";
                };
                
li.appendChild(span);
            };
        };
        
        var 
items sitemap.getElementsByTagName("li");
        for(var 
i=0;i<items.length;i++){
            
//alert("I :"+i+"LEngth :"+items.length);
            
listItem(items[i]);
        };
        
    };    
};

window.onload sitemapstyler