The period function of Hamiltonian systems with separable variables