Dynamics of the Magnetosphere