Friend: Petraeus began affair after taking CIA job