Miscellaneous javascript functions