Consider the complex matrix
\[A=\begin{bmatrix}
\sqrt{2}\cos x & i \sin x & 0 \\
i \sin x &0 &-i \sin x \\
0 & -i \sin x & -\sqrt{2} \cos x
\end{bmatrix},\]
where $x$ is a real number between $0$ and $2\pi$.

Determine for which values of $x$ the matrix $A$ is diagonalizable.
When $A$ is diagonalizable, find a diagonal matrix $D$ so that $P^{-1}AP=D$ for some nonsingular matrix $P$.