Tweak to make this code work with/without jQuery