How are gauge transformations of a $G$-bundle related to the adelic points of $G$? In a very interesting blog discussion at the $n$-category cafe, an anonymous poster made the following remark: "... using the dictionary between number fields and function fields, Weil suggested that G-with-adelic-entries is analogous to the group of gauge transformations of a principal G-bundle over a Riemann surface." 
I would like to know how this particular piece of the number field / function field analogy is made precise. As a preliminary question, does anyone know a reference to where Weil (or someone else) explains it? I have a suspicion that it might be discussed in the notes from Weil's 1959-1960 lectures on "Adeles and algebraic groups", but the copy in my local library is checked out so I'm not sure.
My next question is for an explanation of the analogy in what I assume is the simplest case: holomorphic vector bundles on a compact Riemann surface. There are two obstacles here. First, I don't know what a gauge transformation is, and the "Mathematical Formalism" section 
of the Wikipedia page seems nonsensical to me. What is being transformed, and what is the transformation itself? Can anyone provide a physics-free definition, purely in the language of geometry? 
Now given a curve $X$ over the complex numbers (or any field), we can form a topological ring $\mathbf{A}_X$ as the restricted product of the completed local rings at the closed points of $X$. The second obstacle is that when the ground field is infinite, these completions are not locally compact, so it seems unlikely that $\mathbf{A}_X$ is a good thing to consider. 
Nonetheless, can one put the constructions of the previous two paragraphs together to produce, for any rank $n$ holomorphic vector bundle $\mathcal{E}$ on $X$, a bijection as follows?
$${\text{gauge transformations of }\mathcal{E}}\stackrel{?}{\leftrightarrow} \mathrm{GL}_n(\mathbf{A}_X)$$
My final question is, what is the correct version of this when the complex numbers are replaced by  a finite field? Now we can consider algebraic vector bundles, and even better the adeles of $X$ are now a good thing to consider. So in trying to extend the putative bijection above to this case, the content seems to be in algebraizing the notion of gauge transform. Thus, I'm asking for a (second?) definition of gauge transformation which is native to algebraic geometry, if such exists.
 A: If $X$ is a smooth projective curve over a finite field $k$, with field of rational functions $F$, then the quotient $GL_n(F)\backslash GL_n(\mathbf A_F)/GL_n(\mathcal O_F)$ (where
$\mathcal O_F$ denotes the subring of integral adeles in $\mathbf A_F$) is in natural bijection with the set of isomorphism classes of rank $n$ vector bundles on $X$, i.e. the 
set $Bun_n(k)$ of $k$-valued points of the moduli stack of rank $n$ bundles on $X$.
(And the same should be true if we replace $GL_n$ by another reductive group $G$,
and replace "rank $n$ vector bundles" by principal $G$-bundles; recall that principal $GL_n$-bundles are "the same" as rank $n$ vector bundles; one goes from the latter to the former
by passing to the associate frame bundle.)
The passage from a bundle to an a point in the double coset space is made as follows: given the vector bundle, one chooses an affine open subset $U = X \setminus {x_1,\ldots,x_r}$ over which
the bundle is trivialized, and also trivialiations in a n.h. $U_i$ of each of the points $x_i$.  The gluing data comparing the two trivializations on $U_i \cap U$ gives an element
$g_{x_i} \in GL_n(F_{x_i})$, where $F_{x_i}$ is the completion of $F$ at $x_i$.
If $x$ is a point distinct from the $x_i$, set $g_{x} = 1$.  We can then put all
the $g_x$ together into an adele, and its class in
the double coset space $GL_n(F)\backslash GL_n(\mathbf A_F)/GL_n(\mathcal O_F)$
is independent of all choices.
To see that this map is a bijection, one first observes
that any element in the double coset space can be represented as
$(g_x)$ with $g_x = 1$ for almost all $x$, and then one interprets these $g_x$ as formal
gluing data around the points $x_i$ at which $g_{x_i} \neq 1$ and uses them to 
extend the trivial bundle on $X\setminus {x_1,\ldots,x_r}$ to a bundle on all of $X$.
The relationship with gauge transformations is  that the $g_x$ are change of 
basis matrices (gauge tranformations) in formal punctured n.h.s of the points $x$.
A: I'd like a see an answer to this question, and I hope someone here or on MO can provide a good one.
I just want to address your question about gauge transformations.  Usually a gauge transformation on a principal G-bundle $P\to X$ is simply a G-equivariant map $P\to P$ which sends fibers to fibers (said another way, a gauge transformation is simply an automorphism of the principal G-bundle P).  A great place to read about the basics of gauge transformations is Atiyah and Bott's paper "The Yang-Mills Equations over Riemann Surfaces" (section 2 in particular).  
