misc javascript snippets