Assorted JavaScript helpers