function trim(str, chars) {
	if(str!=undefined)
		return ltrim(rtrim(str, chars), chars);
	return '';
}//end trim
 
function ltrim(str, chars) {
	if(str!=undefined){
		chars = chars || "\\s";
		return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
	}
	return '';
}//end ltrim
 
function rtrim(str, chars) {
	if(str!=undefined){
		chars = chars || "\\s";
		return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	}
	return '';
}//end rtrim

