This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Well, look at the file. Does p1 exist when the script is encountered?
Some people will put the script at the end of the file, after the DOM has been constructed, and there are claims that this is more performant than other locations. (I have yet to see much of any difference.)
But most people will put initialization code in one of a load event handler, or a ready handler (if using jQuery).