There's no need to use any javascript. The easiest solution to this would be to create a class as follows:
Code:
.EDIT { margin: 0px auto 0px auto; width: EDIT; }
What you do would be to to edit the value shown to match your needs. Figure out your largest width value and insert it into the above class. Make sure to take any padding or margins into consideration. Then do something along these lines:
Code:
<body>
<div class="EDIT">
CONTENT
</div>
</body>
That should solve all your problems of centering.