MHD simulations of star-disk magnetospheres and the formation of outflows and jets