title: Detect if a div is in the center and execute some code
body: <p>i need to detect if a div is in the center of the screen and then execute some code - im currently using offset but if the monitor has a high resolution its useless.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  //check to see if elements are at a certain position
  $(document).ready(function () {
  //hide bubble
  $('#bubble02').hide();
  // if div is at 300px execute code
    var videoInterval = setInterval(function() {
    if($('#balloon2').offset().left &lt;= 300){
      $('#bubble02').fadeIn();
    }  
    else if($('#balloon2').offset().left &gt;= 301){
      $('#bubble02').fadeOut();
    } 
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Any help would be appreciated</p>