Useful javascript code