I asked this yesterday but could not reply as i was not registered , I tried out the suggestions that HoLyVieR,Ryan Kinal and Vagabond said, but non of them seem to work.
I have taken out the array as that seem to be the suggested problem and solution but now the code does not work at all but shows no error's.
The original question is here http://stackoverflow.com/questions/3512817/object-expected-error-in-internet-explorer
<script language="JavaScript">
function toggleLayer( whichLayer )
{
var elem, vis,eelem, vvis;
if( document.getElementById ) // this is the way the standards work
elem = document.getElementById( whichLayer );
else if( document.all ) // this is the way old msie versions work
elem = document.all[whichLayer];
else if( document.layers ) // this is the way nn4 works
elem = document.layers[whichLayer];
vis = elem.style;
for (i=0;i<25;i++)
{
eelem = document.getElementById( 'sub'+i );
vvis = eelem.style;
if(eelem==elem){
vvis.display = "block";
} else {
vvis.display = "none";
}
}
if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
</script>