Let $X$ be a continuous random variable with cdf $F(x)$. Suppose that $med(X)$ = 0, show that $\forall z: E(|X-z|) \geq E(|X|)$.
Here is part of the proof I am trying to understand: 
I already figured that the first line is not quite correct because the integration limits were confused. However, I can't follow the step from line 1 to line 2 where we suddenly integrate $F(x)$ and $1-F(x)$. Maybe my probability theory skills aren't very good, but I just can't see what has been done here. Can someone enlighten me?
The error is that the first term should have $z-x$ while the second should have $x-z$, so that the integrand is always positive. Then you get that result using integration by parts. For the first term:
$$\int_{-\infty}^z (z-x) \,dF(x) = (z-z) F(z) - \lim_{y \to -\infty} (z-y) F(y) + \int_{-\infty}^z F(x) \,dx.$$
The first term is trivially zero, the second term is zero because you assume $E[|X|]<\infty$, and so you have what you want there. The situation is similar (but slightly more complicated) in the other term.