title: Variable won't assign in IE7, but assigns perfectly fine in IE8+ and any other browser
body: <p>In this slightly lengthy code snippet:</p>
  <pre><code>(function() {
      var element = function(str) {
          return document.getElementById(str);
          },
  
          parent = document.getElementsByTagName('ul')[0].getElementsByTagName('li'),
          len = parent.length,
  
          swap_slide = function(slide){
              return function(event) {
                  event.preventDefault ? event.preventDefault() : event.returnValue = false;
                  
                  var slides = element('main').getElementsByTagName('div'),
                      len = slides.length;
                  for (var i=0; i&lt;len; i++) {
                      slides[i].style.display = 'none';
                  }
                  slide.style.display = 'block';
              }
          };
  
      for (var i=0; i&lt;len; i++) {
          var link = parent[i].getElementsByTagName('a')[0],
              slide = element(parent[i].getElementsByTagName('a')[0].getAttribute('href').substr(1));
  
          if (link.addEventListener) {
              link.addEventListener('click', swap_slide(slide), false);
          } else if (link.attachEvent) {
              link.attachEvent('onclick', swap_slide(slide));
          }
      }
  
      if (!element(location.hash.substr(1)))
          element('slajd-0').style.display = 'block';
      else 
          element(location.hash.substr(1)).style.display = 'block';
  })();
  </code></pre>
  <p>everything works fine in Chrome, Opera, IE9, IE8, Safari, however in IE7 variable <code>slide</code> is <code>null</code>, IE7 reports the error in the function <code>swap_slide</code>, however the error might be somewhere else. I'm not sure if this is a scope error that I caused or is it simple IE retardation?</p>
  <p><strong>EDIT</strong>: The error IE spits out is:</p>
  <blockquote>
  <p>Error: Unable to get value of the property 'style': object is null or undefined</p>
  </blockquote>