I finally broke down and included jQuery...

Now to convert things...
Removed unsightly regex in favour of jquery