
var validateErrors = new Array();

function validateField(field, validator, errorMsg) {
	if (!validator()) {
		field.style.borderLeft = '4px solid red';
		if (!validateErrors.include(errorMsg)) {
			validateErrors.push(errorMsg);
		}
	}else{
		field.style.borderLeft = '4px solid green';
		validateErrors = validateErrors.without(errorMsg);
	}
}

function check_mail(str)
{
	var pattern = /^([a-zA-Z0-9])[a-zA-Z0-9.-_]{1,}@([a-zA-Z0-9_-]){2,}(\.([a-zA-Z0-9_-]){1,4}){1,2}$/; 
	if(!pattern.test(str))	return false;
	else	return true;
}

function _gel(id){
	return document.getElementById?document.getElementById(id):null;
}

String.prototype.lTrim = function()
{
    return this.replace(/^\s*/, "");
}

// remove trailing whitespace
String.prototype.rTrim = function()
{
    return this.replace(/\s*$/, "");
}

// remove leading and trailing whitespace
String.prototype.trim = function()
{
    return this.rTrim().lTrim();
}
