Theory of spin-polarized bipolar transport in magnetic p-n junctions