Useful JavaScript functions.