/** * File: Utility.js * Author: Brian Borowski * Date created: November 15, 2002 * Date last modified: February 12, 2011 */ /** * Returns true if the string contains only numeric characters and false * otherwise. */ function isOnlyNumeric(string) { var invalidCharactersRegExp = /[^\d]/; var isValid = !(invalidCharactersRegExp.test(string)); return isValid; } /** * Returns the string with leading and trailing whitespace removed. */ function trim(string) { return string.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, ""); } /** * Sets the cursor to be of type cursorType. Valid inputs are "auto" and * "wait". */ function setCursor(cursorType) { // Use regular expressions to get Mozilla-based browsers to change the // cursor back to the default cursor for all document elements. // Any element where the 'hand' cursor is desired must include the 'id' // attribute, and its value must begin with 'link'. var bodyAll; var linkRegExp = /link*./; if (document.body && document.body.all) { bodyAll = document.body.all; } else if (document.body && document.body.getElementsByTagName) { bodyAll = document.body.getElementsByTagName('*'); } if (bodyAll) { for (var i = 0; i < bodyAll.length; i++) { if (linkRegExp.test(bodyAll[i].id)) { bodyAll[i].style.cursor = 'pointer'; } else { bodyAll[i].style.cursor = cursorType; } } } }