A variational principle for the Navier-Stokes equation