String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/, "");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/, "");
}

function validate_string(field, alerttxt) {
	with (field) {
		if (value == null || value == "") {
			alert(alerttxt);
			return false;
		}
		else {
			return true;
		}
	}
}

function validate_number(field, alerttxt) {
	var numericExpression = /^[0-9]+$/;
	with (field) {
		if (!value.match(numericExpression)) {
			alert(alerttxt);
			return false;
		}
		else {
			return true;
		}
	}
}

function validate_radio(field, alerttxt) {
	myOption = -1;
	for (i = field.length - 1; i > -1; i--) {
		if (field[i].checked) {
			myOption = i;
			i = -1;
		}
	}
	if (myOption == -1) {
		alert(alerttxt);
		return false;
	} else {
		return true;
	}
}
