Show $\mathbb{Z}[\sqrt{2}]$ is a PID

I understand how to show something isn't a PID (namely by constructing a counterexample), and I think I understand the proof that $\mathbb{Z}$ is a PID, but I'm not sure how to modify it so that I can show $\mathbb{Z}[\sqrt{2}]$ is a PID. I'm given a hint to let $d(a+b\sqrt{2}):=|a^2-2b^2|$, but I'm not sure how to use a norm to prove that all ideals are principal.

-
Prove that $\mathbb{Z}[\sqrt{2}]$ is Euclidean with respect to the norm $d$. – lhf Mar 12 '12 at 17:11
Alternatively, since $\mathbb{Z}[\sqrt{2}]$ is a Dedekind domain, you can show that it's ideal class group is trivial. – user5137 Mar 12 '12 at 18:40

To show that a ring is a PID it suffices to show that it is Euclidean. On $\mathbb Z[\sqrt{2}]$ we have the norm $N(a+b\sqrt{2}) = |a^2-2b^2|$ which we can extend to $\mathbb Q(\sqrt{2})$, the quotient field of $\mathbb Z[\sqrt 2]$. First note that for each element $x \in \mathbb Q(\sqrt 2)$ we find an element $\tilde x \in \mathbb Z[\sqrt 2]$ with $N(x-\tilde x) < 1$. Namely, if $x = a + b\sqrt 2$, let $\tilde a$ and $\tilde b$ the nearest integer to $a$ and $b$ respectively and let $\tilde x = \tilde a + \tilde b \sqrt 2$. Then $$N(x-\tilde x) = |(a-\tilde a)^2 -2(b-\tilde b)^2| \leq \left(\frac{1}{2}\right)^2 + 2\left(\frac{1}{2}\right)^2 = \frac{3}{4} < 1.$$ Now let $x$ and $y$ be elements of $\mathbb Z[\sqrt 2]$ with $y \neq 0$. We have to show that there exist $k$ and $r \in \mathbb Z[\sqrt2]$ such that $x = ky+r$ and $N(r)< N(y)$. Choose $k \in \mathbb Z[\sqrt 2]$ with $N(x/y - k) < 1$ and let $r = x-ky$. Then $x = ky+r$ and $$N(r) = N(x-ky) = N(y) N(x/y-k) < N(y).$$
This shows that $\mathbb Z[\sqrt 2]$ is Euclidean, hence it is a PID.
No, by "nearest integer" I mean the normal rounding operation, i.e. $\frac{1}{4}$ is rounded down to 0 but $\frac{3}{4}$ is rounded up to 1. This way the difference between a number and its nearest integer is at most $\frac{1}{2}$. – marlu Mar 12 '12 at 20:56