Library of useful JavaScript functions