Gauge invariant perturbations of scalar-tensor cosmologies: The vacuum case