Cosmological horizons and the generalized second law of thermodynamics