My personal favorite is the ternary operator:
var el = document.getElementById(obj);
el.style.display = (el.style.display != 'none' ? 'none' : '' );
You can adjust your examples to use display:none/display:block or visibility:hidden/visibility:visible, which have slightly different ways of rendering.