title: javascript double click problem
body: <p>I have a slideshow which has quick links to the specific slides. The slideshow then continues from that point. The trouble is if I double click on a quick link - when the slideshow continues it skips a slide (if I treble click it skips 2). </p>
  
  <p>I think it's actually a problem with clicking again while the functions are running that's causing the problem as you can achieve the same problem by quickly clicking on other links while the functions are running.</p>
  
  <p>Here's the code I have...</p>
  
  <pre><code>var images=new Array();
  var locationToRevealCount=6;
  var nextimage=2;
  var t;
  var doubleclick;
  
  addIcons();
  
  function addIcons() {
      while (locationToRevealCount&gt;0) {
          $("#extraImageButtons").append('&lt;img class="galleryButtons" src="http://www.steveszone.co.uk/images/button_sets/pink_square_button1n.png" alt="'+locationToRevealCount+'" /&gt;');
          images[locationToRevealCount]='http://www.tombrennand.net/'+locationToRevealCount+'a.jpg';
          locationToRevealCount--;
      };
      $('.homeLeadContent').prepend('&lt;img class="backgroundImage" src="http://www.tombrennand.net/1a.jpg" /&gt;');
      $("#extraImageButtons img.galleryButtons[alt*='1']").attr("src","http://www.steveszone.co.uk/images/button_sets/black_square_button1n.png");
      runSlides();
  }
  
  function runSlides() {
      clearTimeout(t);
      t = setTimeout(doSlideshow,3000);
  }
  
  function doSlideshow() {
      if($('.backgroundImage').length!=0)
          $('.backgroundImage').fadeOut(500,function() {
              $('.backgroundImage').remove();
              slideshowFadeIn();
          });
      else
          slideshowFadeIn();
  }
  
  function slideshowFadeIn() {
      if(nextimage&gt;=images.length) 
          nextimage=1;
  
      $("#extraImageButtons img.galleryButtons").attr("src","http://www.steveszone.co.uk/images/button_sets/pink_square_button1n.png");
      $("#extraImageButtons img.galleryButtons[alt*='"+nextimage+"']").attr("src","http://www.steveszone.co.uk/images/button_sets/black_square_button1n.png");
  
      $('.homeLeadContent').prepend($('&lt;img class="backgroundImage" src="'+images[nextimage]+'" style="display:none;"&gt;').fadeIn(500,function() {
          nextimage++;
          runSlides();
  
      }));
  }
  
  $("#extraImageButtons img.galleryButtons").live('click', function() {
      nextimage=$(this).attr("alt");
      $("#extraImageButtons img.galleryButtons").attr("src","http://www.steveszone.co.uk/images/button_sets/pink_square_button1n.png");
      $(this).attr("src","http://www.steveszone.co.uk/images/button_sets/black_square_button1n.png");
      clearTimeout(t);
      doSlideshow();
  });
  </code></pre>
  
  <p>...</p>
  
  <pre><code>&lt;div class="homeLeadContent" style="width:965px;"&gt;&lt;/div&gt;
  
  &lt;div id="extraImageButtons"&gt;&lt;/div&gt;
  </code></pre>