title: SetInterval loop breaking unexpectedly
body: <p>I have a short piece of code here that I am using to detect when the user stops scrolling. When  it fires the page will switch to the next page. It seems to work once, but when I try to use it again on the next page it breaks and doesn't trigger again. I found out that the timer seems to stop firing after you use it once. I have not managed to find anything related online, so any help would be appreciated. Thanks.</p>
  
  <p>The JQuery:</p>
  
  <pre><code>var scroll = $(window).scroll(function(){
      currentPos = $(window).scrollTop();
      if(currentPos == 0){
          nextPage();
      }
  })
  
  window.setInterval(function(){
      scroll();
  }, 500);
  </code></pre>
  
  <p>The code used to switch pages:</p>
  
  <pre><code>function nextPage(){
      if(document.getElementById("homePage").style.top == "0px"){
          count = 0;
      }
      document.getElementById(pages[count]).style.top = "-1100px";
      count += 1;
      closeMenu();
  }
  </code></pre>