var FormUtil = {

	// Removes leading whitespaces
	LTrim: function(value) {
		var re = /\s*((\S+\s*)*)/;
		return value.replace(re, "$1");
	},

	// Removes ending whitespaces
	RTrim: function(value) {
		var re = /((\s*\S+)*)\s*/;
		return value.replace(re, "$1");
	},

	// Removes leading and ending whitespaces
	trim: function(value) {
		return this.LTrim(this.RTrim(value));
	},

	isEmpty: function(s) {
		return ((s == null) || (s.length == 0));
	},

	isDigit: function(c) {
		return ((c >= "0") && (c <= "9"));
	},

	isInteger: function(s) {
		if (this.isEmpty(s)) {
			return false;
		}

		for (var i = 0; i < s.length; i++) {
			var c = s.charAt(i);

			if (!this.isDigit(c)) {
				return false;
			}
		}
		return true;
	},

	tabNext: function(obj, len, nextField) {
		if (obj.value.length >= len) {
			nextField.focus();
		}			
	}
};
