various javascript snippets