Phase transitions in a confined lattice gas: Prewetting and capillary condensation