JavaScript global timer fired by multiple elements?
<p>I have two jQuery sliders on a page. I would like to fire an event when the user has set both of them. I define "set" as "when both sliders have been idle for 3 seconds".</p>

<p>Can I do something like this, or is it bad practice to create a global variable like this / are there any other problems with the code?</p>

<pre><code>var globalTimer = null;
function myEvent() { 
    alert('Both sliders are set!');
}

$("#slider-1").slider({
  stop: function(event, ui) {
     clearTimeout(globalTimer);
     globalTimer = setTimeout(myEvent, 3000);       
  }
});
$("#slider-2").slider({
  stop: function(event, ui) {
     clearTimeout(globalTimer);
     globalTimer = setTimeout(myEvent, 3000);       
  }
});
</code></pre>
