Averaging, passage through resonances, and capture into resonance in two-frequency systems