The problem is this:
CODE
if (window.document.getElementById(item).style.display == "none")
blah.style.display == "none" won't contain a value at all (or at least, a null value) until it is first set using javascript. So if you want to use this, you are going to have to set all of the items as visible first, then your code will work.