For complex Banach algebra with not-connected spectrum, there is an idempotent for which the following property holds.

Let $A$ be a complex Banach algebra, and suppose that the spectrum of some $x \in A$ is not connected.

Show that $A$ contains a non-trivial idempotent $z$, for which also holds:

$A = A_0 \oplus A_1$, where $$A_0 = \{x : zx = 0\}, \quad A_1 = \{x: zx = x\}.$$

I have been trying to define a function with value $1$ on one part of the spectrum and value $0$ on the other part, and defining the functional calculus $$\tilde{f}(x) = \frac{1}{2\pi i} \int_\Gamma f(\lambda)(\lambda e - x)^{-1} d\lambda.$$

I know that the holomorphic functional calculus is a homomorphism, so if $\Phi_x$ is defined as $\Phi_x(f) = \tilde{f}(x)$ then $(\tilde{f}(x))^2 = \Phi_x(f)\cdot\Phi_x(f) = \Phi_x(f \cdot f)$. But we only know that $f$ has the property $f\cdot f = f$ on $\sigma(x)$, but we are looking on a contour $\Gamma$ that is around $\sigma(x)$, so can also include points which are not in $\sigma(x)$, right? I think I'm missing the point of something..

Also for the second part I'm clueless.

Similar question as here but I didn't really understand the answer to it. Let $A$ be a Banach algebra. Suppose that the spectrum of $x\in A$ is not connected. Prove that $A$ contains a nontrivial idempotent $z$.

$f$ is an analytic function which is $1$ in a neighbourhoood of one part of the spectrum and $0$ in a neighbourhood of the rest. Then $f^2 = f$ on the whole set where it is defined, not just on the spectrum.
For the second part, if $z$ is your idempotent, for any $y \in A$ you can write $y = (1-z) y + z y$...