Molecular theory of weak polyelectrolyte thin films