Several things need to be moved for this to happen
1. Vice-President: If the president died which of these two would you want: a 6-term senator known for his age, experience, and knowledge, or a young, somewhat naive and untested Governor with little national or international acclaim.
2. Media coverage: Obama was seen as this young, intelligent, and relate-able man with enough wit and cunning to back him up, and guide us through. McCain was a veteran and willing to work with people, but couldn't get anyone excited for him. Obama was fresh and McCain kinda old news.
3. Gaffes: Palins and McCains comments on foreign policy, and the economy made people suspicious of how they felt about their capabilities. McCain:"Sure. Technically, I don't know." --asked if the U.S. is in a recession, "60 Minutes" interview, Sept. 21, 2008, Obama kept his mouth closed mostly with potential slip-ups. Biden was a gaffe machine sure, but it wasn't a two hit combo.
4. Party Exasperation: In 8 years Bush started 2 wars, which people didn't know when end was in sight, and rose the already scary deficit up by $5 trillion, betraying the fiscal responsibility the Republican were known for. People were tired of it and want a 180, and Obama seized this opportunity.
All in all if McCain gets a New VP, is a bit more tight lipped on certain subjects, and can distance himself from Bush and his various failures, he could swing over enough people to squeeze in and electoral college victory