title: JQuery show() - halt function until callback is executed
body: <p>I want my javascript/jquery application to stop executing all animations, and only continue executing when a loading .gif is shown. </p>
  
  <p>I did manage to show the loading .gif while other animations where going on, but I really need it to already show before anything else is animated.</p>
  
  <p>So I fabricated a method that waits for the callback to be executed, but it doesn't work as expected. </p>
  
  <pre><code>var Shown = false;
  function ShowLoadingGif() {
      $("#loading").show("fast", function() {
          Shown = true;   
      });
      while(!Shown) {
          //wait for callback to be executed
      }
      Shown = false;
  }
  </code></pre>
  
  <p>See <a href="http://jsfiddle.net/k5Wan/1/" rel="nofollow">this JFiddle example</a>. I would not only like to know how to properly go about solving this problem; I would also appreciate any input as to why it doesn't work as I expect it to.</p>
  
  <p>Thanks in advance!</p>