Given a locally ringed space there is a bijection between open and closed sets of $X$ and idempotent elements of $\mathcal{O}_X(X) $ This is a problem from Gortz and it does NOT assume that the underlying space is the spectrum of the ring or anything like that. Now I proved easily that given a clopen set of $X$ there is an idempotent element of $\mathcal{O}_X(X) $, using the "hint" which glued a section which was the identity on the clopen set $U$ and $0$ on $X-U$. I also know that, given a section of $\mathcal{O}_X(X) $ the set where it restricts to 1 and the set where it restricts to 0 will both be open and that a ring with idempotent $e$ splits as the direct product of $Re$ and $R(1-e)$. I'm pretty sure the answer will use both of these facts but I don't seem to be quite clever enough to put everything together. Any hints??
 Edit: In fact I just noticed the bijection asked for is between idempotent elements of $\Gamma(X, \mathcal{O}_X)  $ and clopen sets of $X$ and so I have an even stupider question : what is the difference between the ring $\mathcal{O}_X(X) $ and the ring $\Gamma(X, \mathcal{O}_X)  $?? 
 A: The key tool is to introduce for any clopen subset $U\subset X$ the global section $e_U\in \mathcal O_X(X)$ defined by: $$e_U\vert _U =1_U\in \mathcal O_X(U),\quad  e_U\vert _{X\setminus U} =0_{X\setminus U}\in \mathcal O_X(X\setminus U)                $$ 
The sheaf axioms for $\mathcal O_X$ ensure that $e_U\in \mathcal O_X(X)$ is a well defined section.
That said, the required bijection is $$\operatorname {Clopen} (X)\stackrel \sim \to  \operatorname {Idempot}(\mathcal O_X(X)):U\mapsto e_U$$ 
The inverse bijection being $$\operatorname {Idempot}(\mathcal O_X(X)) \stackrel \sim \to  \operatorname {Clopen} (X) :e\mapsto U_e:=\{x\in X\vert e_x=1_x\in \mathcal O_{X,x}\}$$ 
Edit
Notice that for a fixed open $U$ we have $(e_U)_x=1_x\in \mathcal O_{X,x}$ for $x\in U$ and $(e_U)_x=0_x\in \mathcal O_{X,x}$ for $x\notin U$.
It is not allowable however to define $e_U$ by these properties: a section of a sheaf is not just a a random collection of germs in its stalks.
However this description of the germs of $e_U$ shows why  $e_{U_e}=e$ for a given $e\in \operatorname {Idempot}(\mathcal O_X(X)) $, as requested by @Roland in his comment.
