Consider jQuery?

Why aren't you using jQuery? Might make your life a bit easier! :-) Check out the bottom of the code to see the jQuery version.