title: javascript alert when element is visible
body: <p>i have the following code:</p>
  
  <pre><code>var blink1 = function() {
      $('.leftArrowMask').hide();
      setTimeout(blink2, 5000);
  };
  var blink2 = function() {
      $('.leftArrowMask').show();
      setTimeout(blink1, 1000);
  };
  $(document).ready(function() {
      setTimeout(blink1, 1000);
  });
  </code></pre>
  
  <p>this basically shows a div for 1 second, and then hides it for 5 seconds.</p>
  
  <p>I would like to display an alert everytime the div is visible.</p>
  
  <p>i have tried the following but it doesnt seem to work:</p>
  
  <pre><code>function checkVisibility(){
    if ($('.leftArrowMask').is (':visible') &amp;&amp; $('.leftArrowMask').parents (':hidden').length == 0)
    alert ("Visible!");
     setTimeout('checkVisibility',1000)//every 1 second...
  }
  </code></pre>
  
  <p>any ideas on what could be wrong?</p>