You could accomplish this with CSS like so:
HTML
<div id="popUpDiv">
Your content here
</div>
CSS
#popUpDiv {
position:absolute;
background-image:url(../images/popup_bg.png);
background-repeat:no-repeat;
top:50%;
width:400px;
height:400px;
margin: -200px auto 0 auto; /* auto, centers horizontally and -120px is half your height to finish the centering vertically */
border:5px solid #000;
z-index: 9002;
}
In conclusion, if you use this method it looks like you may just need to use javascript to dynamically set the height and margin-top value depending on your div and its content at the time.
More information here: http://blog.themeforest.net/tutorials/vertical-centering-with-css/