Stochastic calculus of variations