Jquery Exit Popup
<p>I'm trying to use this tweak for my blog: <a href="http://www.tonylea.com/2011/creating-a-jquery-exit-popup/#comment-909" rel="nofollow">http://www.tonylea.com/2011/creating-a-jquery-exit-popup/#comment-909</a></p>

<p>Basically what it does is the popup should be showing up only when your mouse is moving upward out of the page. </p>

<p>Here's the code:</p>

<pre><code>&lt;script type="text/javascript"&gt;

    var oldPosition = -1;
    $(document).ready(function() {
        $(document).mousemove(function(e) {
            $('#exitpopup').css('left', (window.innerWidth/2 - $('#exitpopup').width()/2));
            $('#exitpopup').css('top', (window.innerHeight/2 - $('#exitpopup').height()/2));

            var position = e.pageY - $(window).scrollTop();
            if(position &lt; 10){
                if(oldPosition != -1){
                    if(position &lt; oldPosition){
                        // Show the exit popup
                        // make sure it's moving upward
                            $('#exitpopup_bg').fadeIn();
                            $('#exitpopup').fadeIn();

                    }
                    oldPosition = position;
                }else{
                    oldPosition = position;
                }
            }
            // $('#divData').html(oldPosition + " : " + position);
        });

        $('#exitpopup_bg').click(function(){
            $('#exitpopup_bg').fadeOut();
            $('#exitpopup').slideUp();
        });
    });
&lt;/script&gt;
</code></pre>

<p><strong>Issue No.1:</strong> Although I don't see there's any problem in the code, the popup does also show up when your mouse is moving down into the page, why is this happening?</p>

<p><strong>Issue No.2:</strong> When you quickly drag your mouse out of the page, nothing shows up. Well, how do I make sure it also works under this situation? </p>
