// Removes leading and trailing spaces from the passed string. Also removes
// consecutive spaces and replaces it with one space. If something besides
// a string is passed in (null, custom object, etc.) then return the input.
if (!window.trim) {
	var trimbody = "if (typeof inputString != 'string') { return inputString; }";
	trimbody += " var retValue = inputString;";
	trimbody += " var ch = retValue.substring(0, 1);";
	trimbody += " while (ch == ' ' || ch == '\\n' || ch == '\\t') {";
	trimbody += "     retValue = retValue.substring(1, retValue.length);";
	trimbody += "     ch = retValue.substring(0, 1);";
	trimbody += " }";
	trimbody += " ch = retValue.substring(retValue.length-1, retValue.length);";
	trimbody += " while (ch == ' ' || ch == '\\n' || ch == '\\t') {";
	trimbody += "     retValue = retValue.substring(0, retValue.length-1);";
	trimbody += "     ch = retValue.substring(retValue.length-1, retValue.length);";
	trimbody += " }";
	trimbody += " while (retValue.indexOf('  ') != -1) {";
	trimbody += "     retValue = retValue.substring(0, retValue.indexOf('  ')) + retValue.substring(retValue.indexOf('  ')+1, retValue.length);";
	trimbody += " }";
	trimbody += " return retValue;";

	var trim = new Function("inputString", trimbody);
}
