I was studying the derivation of Helmholtz decomposition through Wikipedia and I've come across an application of the divergence theorem which I'm not familiar with. I'd appreaciate if you could help me understand it.
Here's the source material: http://en.wikipedia.org/wiki/Helmholtz_decomposition
This is the transition I didn't quite follow, please note that the divergence theorem is applied twice on the equation below, first on the second integral and lastly on the fourth integral, I'm familiar with the former but not with the latter, here it is
1.
$$ \mathbf{F}(\mathbf{r})=-\frac{1}{4\pi}\left[-\nabla\left(-\int_{V}\frac{\nabla'\cdot\mathbf{F}\left(\mathbf{r}'\right)}{\left|\mathbf{r}-\mathbf{r}'\right|}\mathrm{d}V'+\int_{V}\nabla'\cdot\frac{\mathbf{F}\left(\mathbf{r}'\right)}{\left|\mathbf{r}-\mathbf{r}'\right|}\mathrm{d}V'\right)-\nabla\times\left(\int_{V}\frac{\nabla'\times\mathbf{F}\left(\mathbf{r}'\right)}{\left|\mathbf{r}-\mathbf{r}'\right|}\mathrm{d}V'- \int_{V}\nabla'\times\frac{\mathbf{F}\left(\mathbf{r}'\right)}{\left|\mathbf{r}-\mathbf{r}'\right|}\mathrm{d}V'\right)\right] $$
2.
$$\mathbf{F} (\mathbf{r}) =-\frac{1}{4\pi}\left[-\nabla\left(-\int_{V}\frac{\nabla'\cdot\mathbf{F}\left(\mathbf{r}'\right)}{\left|\mathbf{r}-\mathbf{r}'\right|}\mathrm{d}V'+\oint_{S}\mathbf{\hat{n}}'\cdot\frac{\mathbf{F}\left(\mathbf{r}'\right)}{\left|\mathbf{r}-\mathbf{r}'\right|}\mathrm{d}S' \right)-\nabla\times\left(\int_{V}\frac{\nabla'\times\mathbf{F}\left(\mathbf{r}'\right)}{\left|\mathbf{r}-\mathbf{r}'\right|}\mathrm{d}V' -\oint_{S}\mathbf{\hat{n}}'\times\frac{\mathbf{F}\left(\mathbf{r}'\right)}{\left|\mathbf{r}-\mathbf{r}'\right|}\mathrm{d}S'\right)\right]$$
Or more precisely,
$$ \int_{V}\nabla'\times\frac{\mathbf{F}\left(\mathbf{r}'\right)}{\left|\mathbf{r}-\mathbf{r}'\right|}\mathrm{d}V' = \oint_{S}\mathbf{\hat{n}}'\times\frac{\mathbf{F}\left(\mathbf{r}'\right)}{\left|\mathbf{r}-\mathbf{r}'\right|}\mathrm{d}S'$$
I'm not quite sure how the above follows, this is a version of the theorem that I hadn't seen before.
This is sometimes called "The Curl Theorem," for lack of a better name. But it is effectively a disguised version of the Divergence Theorem. We have for the $i$'th component of the integral $\int_V\,\nabla \times \vec A(\vec r)dV$
$$\begin{align} \hat x_i \cdot \left(\int_V\,\nabla \times \vec A(\vec r)dV\right)&=\int_V\,\nabla \cdot (\vec A(\vec r)\times \hat x_i)dV \tag 1\\\\ &=\oint_S\,\hat n \cdot (\vec A(\vec r)\times \hat x_i)dS \tag 2 \\\\ & =\oint_S\,(\hat n \times \vec A(\vec r))\cdot \hat x_i\,dS \tag 3 \\\\ &=\hat x_i \cdot \left(\oint_S\,(\hat n \times \vec A(\vec r))dS\right) \tag 4 \end{align}$$
Inasmuch as $(4)$ holds for all $i$, then we are done!
NOTES:
In arriving at $(1)$, we made use of the vector identity $\nabla \cdot (\vec A\times \vec B)=\vec B\cdot \nabla \times \vec A-\vec A\cdot \nabla \times \vec B$ along with $\nabla \times \hat x_i =0$.
In going from $(1)$ to $(2)$, we used the Divergence Theorem.
In going from $(2)$ to $(3)$, we made use of the triple product's cyclical property.