  We study minimizers of the functional $$ \int_{B_1^+}|\nabla u|^2 x_n^a\,d x
+2\int_{B_1'} (\lambda_+ u^++\lambda_- u^-)\,d x', $$ for $a\in(-1,1)$. The
problem arises in connection with heat flow with control on the boundary. It
can also be seen as a non-local analogue of the, by now well studied, two-phase
obstacle problem. Moreover, when $u$ does not change signs this is equivalent
to the fractional obstacle problem. Our main results are the optimal regularity
of the minimizer and the separation of the two free boundaries
$\Gamma^+=\partial'\{u(\cdot,0)>0\}$ and $\Gamma^-=\partial'\{u(\cdot,0)<0\}$
when $a\geq 0$.
