I have found some code (source lost, i'm afraid) that shows and hides divs to give a tabbed approach to a page. One part of the code hides all DIV with an id starting "sec" + an integer (sec1, sec2..).
My issue is that i want the most efficient code - this sample is hard coded for 3 div (sec1, sec2, sec3) but other pages will have more or fewer divs, so i would like to amend this code to iterate thru all secX divs, no matter how many or few.

Code is

if (ng5) document.getElementById('sec1').style.visibility = "hidden"
else if (ns4) document.sec1.visibility = "hide"
else if (ie4) sec1.style.visibility ="hidden"

if (ng5) document.getElementById('sec2').style.visibility = "hidden"
else if (ns4) document.sec2.visibility = "hide"
else if (ie4) sec2.style.visibility ="hidden"

if (ng5) document.getElementById('sec3').style.visibility = "hidden"
else if (ns4) document.sec3.visibility = "hide"
else if (ie4) sec3.style.visibility ="hidden"
Thanks in advance for any help!!