Amount of quadratic residues and nonresidues modulo p

I cannot find a proof/ reasoning behind the following statement:

If p is an odd prime then among the integers in $\displaystyle [1,p-1]$ there are exactly $\displaystyle \frac{p-1}{2}$ quadratic residues and exactly $\displaystyle \frac{p-1}{2}$ nonresidues.

My text says the reasoning behind this follows from the following fact:

Let $\displaystyle g$ be a primitive root modulo $\displaystyle p$ and assume $\displaystyle \gcd(a,p)=1$. Let $\displaystyle r$ be any integer such that $\displaystyle g^r\equiv{a}(mod\,p)$. Then $\displaystyle r$ is even if and only if $\displaystyle a$ is a quadratic residue modulo $\displaystyle p$.

But I don't really see how that follows from this. Any help would be appreciated.

Thanks.

Re: Amount of quadratic residues and nonresidues modulo p

There is a proof on this page: Quadratic Residues