I don't think you are going to be able to get this to work. Google
Sites inserts gadgets on the page using a separate iframe for each
gadget, and the contents of that iframe can't access the contents of
the surrounding window. This is because the iframe contents comes
from a different domain than the window that contains it, so the
browser's same-origin security policy prevents the iframe from
accessing the containing window. From the looks of things, Google
Sites has done this on purpose to isolate the gadget from the rest of
the page, preventing it from affecting the site outside of the frame
that it is given when you add it to the page.
I don't see any way around this in Google Sites. if you come up with
one, I'd be very interested in hearing about it.
Davide