A set of useful javascript functions