Positioning a div or dialog to the center of the window
<p>I am using this following code to position the dialog to the center of the window.</p>

<pre><code>var dialog = $('#dialogBox');
var windowHeight = $(window).height();
var windowWidth = $(window).width();
var dHeight = $('#dialogBox').height();
var dWidth = $('#dialogBox').width();
$('#dialogBox').css({top:windowHeight/2 - dHeight/2, left:windowWidth/2 - dWidth/2}).show();
</code></pre>

<p>It positions the div to the center of the window. But i wants to position the dialog to the center of current visible area. So the dialog will be positioned center of the window even if i scroll down or scroll up. How to do it with jquery?</p>

<p>Any suggestions would be appreciative!!!</p>

<p>Thanks.</p>
