title: Problems with setInterval/clearInterval
body: <p>I have some code which I am trying to use for a gallery, it takes URLs from an array then changes an image on the page. Starting the gallery works fine</p>
  
  <pre><code>var move = window.setInterval(function(){gallery_switch_script()},2000);
  </code></pre>
  
  <p>But when I try to clear it within a function it doesn't clear the interval but the rest of the function does work but it only works once</p>
  
  <pre><code>function bwd(){
  clearInterval(move);
  var move = setInterval(function(){gallery_switch_script()},2000);
  var b = i-1;
  var valueBwd = array[b];
  $(".galleryImg").fadeOut(1500,function(){$(".galleryImg").attr("src",valueBwd);});
  $(".galleryImg").fadeIn(1500);
  </code></pre>
  
  <p>}</p>
  
  <p>This spits out no errors at all. This seems to be the only part of the code which doesn't want to work, apart from the fast-forward button which contains a clearInterval() also.</p>
  
  <pre><code>var array = new Array();
  array[0] = "";
  array[1] = "img/gallery_1.png";
  array[2] = "img/gallery_2.png";
  array[3] = "";
  array[4] = "";
  array[5] = "";
  array[6] = "";
  array[7] = "";
  array[8] = "";
  array[9] = "";
  array[10] = "";
  array[11] = "";
  array[12] = "";
  array[13] = "";
  array[14] = "";
  array[15] = "";
  array[16] = "";
  array[17] = "";
  array[18] = "";
  array[19] = "";
  
  window.onload=function(){var move = window.setInterval(function()     {gallery_switch_script()},2000);};
  
  var i = 0;
  
  function gallery_switch_script(){
  
  var value = array[i]
  i+=1;
  $(".galleryImg").fadeOut(1500,function(){$(".galleryImg").attr("src",value);});
  $(".galleryImg").fadeIn(1500);
  
  }
  
  function fwd(){
  window.clearInterval(move);
  var move = setInterval(function(){gallery_switch_script()},10000);
  gallery_switch_script();
  }
  
  function bwd();
  clearInterval(move);
  var move = setInterval(function(){gallery_switch_script()},2000);
  var b = i-1;
  var valueBwd = array[b];
  $(".galleryImg").fadeOut(1500,function(){$(".galleryImg").attr("src",valueBwd);});
  $(".galleryImg").fadeIn(1500);
  }
  </code></pre>
  
  <p>This is all of my code.</p>