McCain had a slight lead right up until the economy collapsed. Given how weak McCain was, Obama should have been much further ahead. Obama wasn't closing the deal.
If a white US senator from Chicago who was only recently elected, who had run for state office in 1994 as a socialist, who worked and was friends with a domestic terrorist, who attended a church where the pastor regularly spewed racist hatred, who had refused to wear a flag lapel pin after 9/11 and whose wife had made disparaging remarks about the US, who advocated leaving infants to die after they had emerged from the womb following botched abortions, who talked about "redistributing the wealth," who promised to run the coal industry out of business...if that candidate had been on the ballot, he wouldn't have gotten near the general election. No amount of money could have propped him up, and no media fawning would have kept the public from seeing the candidate for who he was.
Barack Obama was elected because: a) the people wanted someone other than Bush; and b) they wanted to elect a black man to make history.