title: Slide show has a strange behaviour
body: <p>My slide show (Javascript) works properly since the last slide, but when it be restarted, doesn't stop the assigned freeze time. It is my js code:</p>
  
  <pre><code>var pos;
  var slides;
  var timeOut;
  var slideTime = 3000;
  
  window.onload = function (){
      pos = -1;
      var slideContent = document.getElementById("slides");
      slides = slideContent.getElementsByTagName("article");
      initSlides();
  };
  
  function initSlides(){
      if (pos !== -1){
          pos++;
          if (pos === slides.length){
              pos = 0;
              exitSlide(slides[slides.length-1], slides[pos]);
          }else{
              exitSlide(slides[pos-1], slides[pos]);
          }
      }else{
          pos ++;
          slides[pos].style.display = "block";
          timeOut = setTimeout(initSlides, slideTime);
      }
  }
  
  function changeSlide(next){
      if (next){
          pos++;
          if (pos === slides.length){
              pos = 0;
              exitSlide(slides[slides.length-1], slides[pos]);
          }else{
              exitSlide(slides[pos-1], slides[pos]);
          }
      }else{
          pos --;
          if (pos === -1){
              pos = slides.length - 1;
          }
      }
  }
  
  function enterSlide(obj){
      obj.style.display = "block";
      var left = obj.offsetLeft;
      var current = obj.offsetWidth;
      obj.style.marginLeft = current + "px";
      function frame(){
          current -= obj.offsetWidth/120;
          if (current &gt;= left){
              obj.style.marginLeft = current + "px";
          }else{
              clearInterval(id);
              timeOut = setTimeout(initSlides, slideTime);
          }
      }
  
      var id = setInterval(frame, 1);
  }
  
  function exitSlide(obj, objNext){
      clearTimeout(timeOut);
      var left = obj.offsetLeft;
      var current = -obj.offsetWidth;
      function frame(){
          left += current/120;
          if (left &gt;= current){
              obj.style.marginLeft = left + "px";
          }else{
              clearInterval(id);
              obj.style.display = "none";
              enterSlide(objNext);
          }
      }
  
      var id = setInterval(frame, 1);
  }
  </code></pre>
  
  <p>The inspect code console doesn't give me any error, but slide show is so bugged. Since second turn the slides doesn't stop and some time latter, the slides sometimes stops, sometimes be showed but without transaction and sometimes means that works properly but the next slide is bugged too. I don't know why it happends. If you can, help me please.</p>