Well, you do it like you would do it normally. You insert the <SCRIPT> and </SCRIPT> tags in the head of the document. Then you open the window...
<HTML>
<HEAD>
<TITLE>%title%</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- Début
window.open("document.html", "window_name", "parameters");
// Fin -->
</SCRIPT>
</HEAD>
<BODY ...>
[...]
</BODY>
</HTML>
You add the php code with <? and ?> (or <?php and ?>).
Is it clear ?