title: Object expected error in Internet Explorer
body: <p>The code works as it should in Firefox and Chrome.</p>
  <p>When the page loads in Internet Explorer, you get the error</p>
  <blockquote>
  <p>User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; eSobiSubscriber 2.0.4.16; FDM; InfoPath.3)
  Timestamp: Wed, 18 Aug 2010 13:48:54 UTC</p>
  </blockquote>
  <p>and when you press a link</p>
  <pre><code>&lt;a href=&quot;javascript:toggleLayer('sub&lt; ? echo $l; ?&gt;');&quot;&gt;&lt;? echo $alp[$l]; ?&gt;&lt;/a&gt; 
  </code></pre>
  <p>you get the error</p>
  <blockquote>
  <p>Message: Object expected<br />
  Line: 4<br />
  Char: 1<br />
  Code: 0<br />
  URI:</p>
  <p>Message: Object required<br />
  Line: 24<br />
  Char: 4<br />
  Code: 0<br />
  URI:</p>
  </blockquote>
  <p>There are no errors in Firefox or Chrome, just IE.</p>
  <p>Any help would be appreciated.  Here is my code:</p>
  <pre><code>function toggleLayer( whichLayer )
  {
    var sub=new Array();
    for (i=1;i&lt;25;i++)
    {
    sub[i] = 'sub'+i;
   }
    var elem, vis;
    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;
    // if the style.display value is blank we try to figure it out here
    
  
    
    for (i=1;i&lt;26;i++)
   {
     eelem = document.getElementById( sub[i] );
     vvis = eelem.style;
     if(eelem==elem){
      vvis.display = &quot;block&quot;;
      } else {
      vvis.display = &quot;none&quot;;
      }
   }
   
    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';
  }
  </code></pre>