I suggest the following solution:
1) In JS when you want to show a window:
{
var width = $(window).width();
var heigth = $(window).height();
var myWindow = $('.my-window');
myWindow .show('fast');
myWindow .offset(
{
left: (width - myWindow .width()) / 2 + $(window).scrollLeft(),
top: (heigth - myWindow .height()) / 2 + $(window).scrollTop()
});
}
2) in CSS:
.my-window
{
position: fixed;
}