title: Synchronous delay in code execution
body: <p>I have a code which needs to be executed after some delay say 5000 ms.Currently I am using setTimeout but it is asynchronous and i want the execution to wait for its return. I have tried using the following:</p>
  
  <pre><code>function pauseComp(ms) 
   {
       var curr = new Date().getTime();
       ms += curr;
       while (curr   &lt; ms) {
           curr = new Date().getTime();
       }
   } 
  </code></pre>
  
  <p>But the code i want to delay is drawing some objects using raphaeljs and the display is not at all smooth. I am trying to use doTimeout plugin. I need to have a delay only once as the delay and code to be delayed are both in a loop. I have no requirement for a id so I am not using it.
  For example:</p>
  
  <pre><code>for(i; i&lt;5; i++){ $.doTimeout(5000,function(){
           alert('hi');  return false;}, true);}
  </code></pre>
  
  <p>This waits for 5 sec befor giving first Hi and then successive loop iterations show alert immediately after the first. What I want it to do is wait 5 sec give alert again wait and then give alert and so on. </p>
  
  <p>Any hints/ suggestions are appreciated!</p>