The scattering of Lyman-series photons in the intergalactic medium