<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head><title></title>
  
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
 <script type="text/javascript">
  
  $(function(){
   
  var win = $(window);
  
  function centerBox(){
    var box = $("#box");
    box.css("left", win.width() / 2 - box.width() / 2); 
    box.css("top", win.height() / 2 - box.height() / 2); 
  }
  
  centerBox();
  
  win.resize(centerBox);
  
  });
  </script>
  <style type="text/css">
 
     #box{
       position: absolute;
       width : 500px;
       height : 200px;
       background-color: red;
     }
    
  </style>
  </head>
  
  <body>
  
     
      <div id="box">
     
      </div>
      
    
  </body>
</html>
