Some useful JavaScript code