Miscellaneous javascript code