Sometimes javascript should run above the HTML it acts upon and sometimes it should run after. Although you can put the script within a div element, mixing up your HTML and your scripts is considered messy, but if you have a reason to to it you can.
HTML is run sequentially, but (usually) javascript sits in memory until it is called. I think your problem is not the placement of your javascript, but the HTML around your slideshow.
If the slideshow is "stuck on the header" then try putting <br style='clear:both'/> right before the div that contains the slideshow. If that doesn't help, show us more of the code involved.