I usually use this function, it work fine

Code:
var ie = (document.all) ? true : false;
function toggleObj(obj) {
  
     try{
        var el;
        try{
        
            el = (ie) ? document.all(obj) : document.getElementById(obj);
        }
       catch(err)
       {
            el= document.getElementById(sm);
       }

        if ( el.style.display != 'none' ) {
            el.style.display = 'none';
            
        }
        else {
            el.style.display = 'block';
            
        }
    }catch(err)
    {
    
    }
}