I've seen this movie before, when President Nixon began troop withdrawals from Vietnam. It doesn't end prettily, IMHO. On the other hand, no one has come up with a better idea, so it may be inevitable. Defeat in Vietnam led to a collapsed American economy that didn't recover until Ronald Reagan decided to win the Cold War. I believe the economy is linked to the war. When America is losing wars, our economy suffers. When we won the Cold War, the economy benefitted.
So, if Obama reprises the Nixon and Carter eras, it's going to be a long four years. He might get away with losing Iraq if he really wins Afghanistan...but if America is driven out of Kabul in disgrace, IMHO it means a Republican landslide in 2010, and a Republican in the White House in 2012.