Object expected error in Internet Explorer
<p>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.</p>

<p>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.</p>

<p>The original question is here <a href="http://stackoverflow.com/questions/3512817/object-expected-error-in-internet-explorer">http://stackoverflow.com/questions/3512817/object-expected-error-in-internet-explorer</a></p>

<pre><code>&lt;script language="JavaScript"&gt;
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&lt;25;i++)
{
    eelem = document.getElementById( 'sub'+i );
    vvis = eelem.style;
    if(eelem==elem){
        vvis.display = "block";
    } else {
        vvis.display = "none";
    }
}

  if(vis.display==''&amp;&amp;elem.offsetWidth!=undefined&amp;&amp;elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&amp;&amp;elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
&lt;/script&gt;
</code></pre>
