Roger got a little lucky with the Olympics messing up the schedules, so he has a chance to hold on to his number one ranking for a couple of weeks longer than he should have. His fate (at least for this week) is in his hands. As long as he makes the semifinal, he will still be number one after this week, even if Rafa wins the tournament. The week after that, he still has a marginal chance of retaining number one, if he wins the Olympics.
Let’s look at the bright side, Roger will have plenty of opportunities to regain the top ranking early next year. Rafa won’t be number one for long, if Roger plays his best. He should just concentrate on salvaging this season (U.S. Open, year-end Masters Cup and a couple of masters series events) and start on a clean slate next year.
He will start off with a clean slate next year, but if Nadal winds up with a huge lead after this year, he will have #1 protected for quite a while next year unless somehow he doesn't win during the clay season which is about as unlikely as George Bush converting to Islam right now. If Federer has a strong end of the year, he can retake #1 early next year.