A Variational Formulation for Gravity-Capillary Waves In A Layered Fluid