some javascript snippets