Changed to use jQuery where possible.