How do i get relative dimensions of scrollbale window viewport
<p>I am having a Tooltip (larger image view) that is being positioned via e.pageX e.pageY and i am trying to make sure it is not hidden below the current scrolled view port.</p>

<p>I have seen many sites have this
my code is something like this but i am missing something.</p>

<pre><code>var positionImg = function(e) {
    var viewportWidth = $(window).width(); 
    var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();  
    var mouseAtY = e.pageY;
    var mouseAtX = e.pageX;
    var maxBottomVPos = viewportHeight-"i dont know";
    var maxTopVPos = 30;

    if (mouseAtY &gt;= maxBottomVPos)
    {
        tPosX = mouseAtX+ 10;
        tPosY = mouseAtY -520;
    }
    else if (mouseAtY &lt;= maxTopVPos)
    {
        tPosX = mouseAtX;
        tPosY = mouseAtY +40;
    }
    else
    {
        tPosX = mouseAtX;
        tPosY = mouseAtY +20;  
    }
    $zoomContainer.css({top: tPosY, left: tPosX});
};
</code></pre>
