function F_isEmpty() {
	if (this.trim() == "") return true;
	return false;
}
function F_ltrim() {
	var str = this;
	if (str.length == 0)
		return str;
	while (str.charAt(str.length - 1) == " ") {
		str = str.substring(0, str.length - 1);
	}
	return str;
}
function F_rtrim() {
	var str = this;
	if (str.length == 0)
		return str;
	while (str.charAt(0) == " ") {
		str = str.substring(1, str.length);
	}
	return str;
}
function F_trim() {
	return this.ltrim().rtrim();
}
function F_isEmail() {
	// determine if a reasonably valid email
	var str = this;
	if ((str.indexOf("@") > 0) && (str.indexOf(".") > 2) && (str.indexOf(".") < str.length - 1) ) {
		return true;
	} else {
		return false;
	}
}
function F_isNum() {
	var bResult = true;
	if (this.isEmpty()) bResult = false;
	for (var i=0; i<this.length; i++) {
		if (!isNumericChar(this.charAt(i))) {
			bResult = false;
		}
	}
	return bResult;
}
String.prototype.isEmpty = F_isEmpty;
String.prototype.ltrim = F_ltrim;
String.prototype.rtrim = F_rtrim;
String.prototype.trim = F_trim;
String.prototype.isEmail = F_isEmail;
String.prototype.isNum = F_isNum;

function isNumericChar(c) {
	if (c != "0") {
		if (!parseInt(c))
			return false;
	}
	return true;
}
function isNum(n) {
	var bResult = true;
	if (isEmpty(n)) bResult = false;
	for (var i=0; i<n.length; i++) {
		if (!isNumericChar(n.charAt(i))) {
			bResult = false;
		}
	}
	return bResult;
}

function isPhone(str) {
	return (matchesPattern(str, "###-###-####") || matchesPattern(str, "(###)###-####") || matchesPattern(str, "##########") || matchesPattern(str, "(###) ###-####") || matchesPattern(str, "#-###-###-####") || matchesPattern(str, "(###)#######") || matchesPattern(str, "### ### ####"));
}

function matchesPattern(str, pat) {
	// see if any wildcards
	if (str.length != pat.length)
		return false;
	for (i=0; i<pat.length; i++) {
		x = pat.charAt(i);
		if (x=="#") {
			if (!isNumericChar(str.charAt(i))) return false;
		}
		else if (x=="a") {
			if (!isAlphaChar(str.charAt(i))) return false;
		}
		else {
			if (str.charAt(i) != x) return false;
		}
	}
return true;
}