// BOI, followed by one or more digits, followed by EOI.
// BOI, followed by one or more digits, followed by a decimal, followed by one or more digits, followed by EOI.
var onlyDigit = /^\d+$/
var digitDecimal = /^\d+\.\d+$/
var errorMsg = "This field must contain a valid numeric value\n(Eg., 100 or 100.00)"


var defaultEmptyOK = true

function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}

function isDigi (s) {
	if (isEmpty(s)) {
		if (isDigi.arguments.length == 1) return defaultEmptyOK;
		else return (isDigi.arguments[1] == true);
	} else {
		return (onlyDigit.test(s)) || (digitDecimal.test(s))
	}
}

function checkDigi (theField, emptyOK) {
	if (checkDigi.arguments.length == 1) emptyOK = defaultEmptyOK;
	if ((emptyOK == true) && (isEmpty(theField.value))) return true;
	else if (!isDigi(theField.value, false)) {
		alert(errorMsg);
		theField.focus();
	}
}


