String.prototype.trim = function() {
	var s = this;
	s = s.replace(new RegExp("^(\\s)*", "g"), "");
	s = s.replace(new RegExp("(\\s)*$", "g"), "");
	return s;
}

function validateRequiredTextbox(textBox, requiredMsg) {
	if (textBox == null || !textBox.tagName || textBox.tagName != "INPUT")
		return true;
	var v = textBox.value.trim();
	if (v == "") {
		alert(requiredMsg);
		textBox.focus();
		textBox.select();
		return false;
	}
	return true;
}

function validateEmailTextBox(textBox, invalidMsg) {
	if (textBox == null || !textBox.tagName || textBox.tagName != "INPUT")
		return true;
	var v = textBox.value.trim();
	var re = new RegExp("^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\w+)*$", "g");
	if (!v.match(re)) {
		alert(invalidMsg);
		textBox.focus();
		textBox.select();
		return false;
	}
	return true;
}