Some javascript helper functions.