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