Faced with a demotion at work due to a drinking problem, Osbourne Cox angrily quits his job as a CIA analyst and resolves to write a memoir about his life and career. When his pediatrician wife Katie finds out, she sees it as a justifiable opportunity to file for divorce and continue her adulterous affair unimpeded. Taking her lawyer's advice, she copies financial records and several other files from her husband's computer onto a CD. These files contain a rambling, meaningless diatribe by Cox on purported CIA activities.
When the CD gets left on the locker room floor of Hardbodies, a local gym, by a careless law firm employee, it falls into the hands of dim-witted personal trainer Chad Feldheimer and his co-worker Linda Litzke, who mistakenly believe the numerical data in the Coxes' bank records, and especially, Cox's diatribes, to be highly sensitive government information. After getting the data traced back to Osbourne, who thinks his memoirs have been stolen, Chad and Linda plan to give the disc back to him for a reward, with Linda planning to use the money to pay for plastic surgery. When a phone call and subsequent meeting with Osbourne provoke a furious reaction and go horribly wrong, Chad and Linda turn over the disc to the Russian embassy, offering more information in return for monetary compensation. With no other data to give them, Linda persuades Chad to sneak into the Coxes' home to get more files from their computer.
Meanwhile, Osbourne's increasingly erratic behavior, aggravated in part by his encounters with Chad and Linda, prompt Katie to move ahead with the divorce proceedings. She changes the locks on their house, forcing Osbourne to move onto the sailboat they have docked on the Chesapeake Bay. With her husband out of the picture, Katie invites her lover, Harry Pfarrer, to move in. A womanizing, multi-adulterous deputy U.S. Marshal, Harry is coincidentally also secretly seeing Linda. Harry finds Chad, whom Linda sent to find more files on Osbourne, hiding in a wardrobe in the Coxes' home, panics, and fatally shoots Chad.
Two days later at the CIA headquarters, Palmer Smith, Osbourne's former superior, and his director learn that information from Osbourne has been given to the Russian Embassy. The two men are perplexed, given Osbourne's low-level security clearance, the material delivered to the Russians being of no importance to anyone, and the apparent motive of all involved parties remaining unknown. Smith is told to maintain observation until the situation "makes sense". Harry, burdened by keeping the day prior's events secret, gets into an argument with Katie and decides to leave the house. On his way out, he spots a man who has been trailing him for the past several days. After tackling him to the ground, Harry finds out that the man is a private detective hired by his wife Sandra "Sandy" to gather evidence for impending divorce proceedings. Sandy is shown to be having an extramarital liaison of her own. Harry is devastated and goes to see an agitated Linda, who confides in Harry that Chad is missing. Harry agrees to help find Chad.
The next morning, Harry and Linda meet in a park, and Linda provides him with more information about Chad's disappearance. When Linda mentions the name "Osbourne Cox", Harry figures out that Chad is the man he shot. He panics, realizes that there are strange men in the park (most likely the CIA people trailing Linda) and flees, assuming Linda is a spy. Linda then turns to Ted Treffon, the kindhearted manager of Hardbodies, who has unrequited feelings for her and has been critical of Linda and Chad's scheming thus far. Believing the Russians have kidnapped Chad, he agrees to go to the Coxes' home to search Osbourne's computer. Unemployed and having spent the past several days living on a small boat, Osbourne becomes unhinged when he finds out that Katie has emptied his bank accounts and, no longer having keys, decides to break into the house to get some of his personal belongings. Finding Ted in the basement, Osbourne initially takes him to be Katie's lover. He soon realizes Ted's affiliation with Linda and what he refers to as the "league of morons" he feels that he has been struggling against his whole life and kills Ted.
At CIA headquarters a few days later, Palmer and his director try to understand what exactly happened. It is revealed that while trying to board a flight to Venezuela, Harry was detained because his name was on a hot list and that the CIA is holding Linda, who is promising to "play ball" and "sit on it" if they will pay for her plastic surgery. A CIA agent shot Osbourne during his assault on Ted and the bullet has put Osbourne in a coma. The director instructs Palmer to let Harry fly to Venezuela (as that country has no extradition treaty with the US and therefore will not send him back) and pay for Linda's surgery. The director and Palmer conclude that despite their oversight and the unusual events that have unfolded, there appears to be no lesson for the agency to have learned, be it moral, espionage, or otherwise. "I guess we learned not to do it again," the director concludes (despite not knowing exactly what they did), and closes his file.
Meanwhile, staff at the Russian embassy have dismissed the contents of Cox's ramblings in the files from his computer - arguably the one factor that started off the entire chain of events - as "drivel".

Question: When was Pfarrer detained?
Answer: while he was trying to board a flight to Venezuela