Geometries and Properties of Excited States in the Gas Phase and in Solution. Theory and Application of a Time-Dependent DFT Polarizable Continuum Model