title: temporarily block the UI, and run a callback
body: <p>For sake of simplicity, I want an all purpose function to block the UI (ie click events, but maybe not hover etc.) , and optionally run a callback when it's done.  So far I have this:</p>
  
  <pre><code>blockedUI=false;
  function blockUI(milliseconds,callback)
  {
      blockedUI=true;
      if (callback===undefined)
          setTimeout(function(){blockedUI=false;},milliseconds);
      else
          setTimeout(function(callback){blockedUI=false;callback();},milliseconds);
  }
  
  function itemClicked(item)
  {
     if(blockedUI)return;
  
     //handle click
  }
  
  blockUI(1000,function{alert("UI is now available");});
  </code></pre>
  
  <p>basically, whenever I handle something, I'll check if the UI is curently "blocked".   My specific problem here is actually that I can't figure out how to pass the callback function along to the anonymous function that I'm passing to setTimeout.   </p>
  
  <p>The real question is, how can I pass the callback parameter and call it in the body of the setTimeout anonymous function parameter</p>