Fixing up javascript weirdness