I recently had some trouble with code like this...
style.display (or style.visibility) might actually be undefined or an empty string, so I ended up using code like this...
code:
if(typeof(wdzElement.style.display) == "undefined" || wdzElement.style.display == "none" || wdzElement.style.display == "") {
wdzElement.style.display = "block";
} else {
wdzElement.style.display = "none";
}