Mechanism for Exciting Planetary Inclination and Eccentricity through a Residual Gas Disk