You've asked a couple of questions:
Short Answer: it's the number of links, not how they are coded that is the issue.
Long Answer:
If your dropdown links to hundreds of
pages, does having this large
unordered list at the top of every
page's code hurt that page's SEO
(because there is all of that
non-page-specific code at the top)?
It can, but like anything on the web, it comes down to implementation. It's not so much the code used to put the menu that would impact your SEO, but more the fact that you're dividing your page's linking equity (PageRank) by a larger number of links. This isn't an issue if you are a popular site with high PR, but if you're not, you'd want to be more selective about how/where you're linking internally. The actual code used to make up that navigation isn't as much of an issue as the way you're including those links, since search engines mostly ignore the markup (including HTML5).
Would it be better to use javascript
to inject the contents of the UL from
the bottom of the code or to have the
UL at the bottom but use CSS
positioning to get it up top
This will help with the content being closer to the H1/body tag being given preferential weighting, but you're still not dealing with the number of links issue. I have tried the CSS positioning method as a test, and it had a negative impact on the value of the main navigation elements because they were given "footer" weighting in the eye of the search engines.
Summary:
So the answer really is, for SEO - don't use mega-menus if you're a small site because you simply can't spread the link equity proportionately to the pages that need it - you'll need to ensure your most important pages are linked to from your homepage, then link deeper as you traverse your site architecture. If you've got PR of 6 or higher or a lot of higher PR pages, then you could consider linking deeper from your main menus.
As for usability issues - that's been pretty much debunked by the large number of large sites that use them successfully.
Further reading (and examples):
- http://www.smashingmagazine.com/2009/03/24/designing-drop-down-menus-examples-and-best-practices/