Some javascript utility functions