javascript code snippets that may be useful