function trim(string){
    return string.replace(/^\s*|\s*$/g,'');
}

function ltrim(string){
    return string.replace(/^\s*/g,'');
}

function rtrim(string){
    return string.replace(/\s*$/g,'');
}

// Checks for a blank field
function isBlankField(field) {
	return (field.value == "");
}

//Checks the lenght of the string
function isValidLenght(field, lenght) {
	return (field.value.length == lenght);

}

//Checks the lenght of the string
function isMaxLenght(field, lenght) {
	return (field.value.length <= lenght);
}

//Checks the lenght of the string
function isMinLenght(field, lenght) {
	return (field.value.length >= lenght);
}

// Checks for a "@" in email address
function isValidEmail(str) {
	var atPosition = str.indexOf('@');
	var dotPosition = str.indexOf('.', atPosition);
	return ((atPosition && dotPosition) > 0);
}

// Checks that a string contains only numbers
function isNumber(field) {
	str = field.value;
	retValue = false;
	for ( var position = 0; position < str.length; position++) {
		var chr = str.charAt(position);
		if ((chr < '0') || (chr > '9'))
		{
			retValue= false;
			break;
		}
		else
		{
		 retValue = true;	
		}
		}
	return retValue;
}

//Checks that a string contains only characters
function isChar(field) {
	str = field.value;
	retValue = false;
	for ( var position = 0; position < str.length; position++) {
		var chr = str.charAt(position);
		if ((chr < '0') || (chr > '9'))
		{
			retValue= true;
		}
		else
		{
		 retValue = false;
		 break;
		}
		}
	return retValue;
}
