Some JavaScript is put direct into the head of the page, rather than external files, because it's specific to that page. Some of it is also dynamic such as the list of tags for auto completion - they also change after every few questions are asked and are specific to your site so cannot be in external files.
As for why JavaScript is at the top, it's because plugins can use jQuery and so could output jQuery code in the middle of the page, so it needs to be included before then. It's not a big performance issue in my experience.