Where you put the code for the pop-up depends on where the author wants you to put it. By convention, most scripting should go in the HEAD section of your page.
The makeup of a typical webpage should be
.....
.......
.......
.......
(from http://www.w3.org/TR/html401/struct/global.html#h-7.1 - HTML 4.01 standards)
The HEAD section contains information about the page, scripting and references to external files (CSS files etc.)