Hi, im trying to add "layered" images to my website, and i cant seem to do it without javascript, and now ive got a problem with it.

the script "works" (to the best of my knowledge, havent done this before), but for some reason, if i try to use window.onresize, the website itself goes completely blank (just the javascript image is visible).

the code is as follows if anyone could be so kind as to help me out, and tell me what im doing wrong.

Code:
<script type="text/javascript" language="javascript"> 
var aw = window.screen.availWidth
var cw = aw/2 
var pw = cw - 543 
</script>  

<script type="text/javascript" language="javascript">
document.write("<div style='position: absolute; left:" + pw + "; top: 195;'>");
document.write("<a href='mailto:admin@superpokerforums.com?subject=Advertising'><img src='layout/advert.gif' border=0>");
document.write("</div>");
</script>
now ive tried defining the document.write sections as a function, say getPic();, moved the whole script to the header, and added the parameter window.onresize = getPic;

ideas?