Javascript helper functions.