function escapeRegex(text) {
	if (!arguments.callee.sRE) {
		var specials = [
			'/', '.', '*', '+', '?', '|', '^',
			'(', ')', '[', ']', '{', '}', '\\'
		];
		arguments.callee.sRE = new RegExp(
			'(\\' + specials.join('|\\') + ')', 'g'
		);
	}
	return text.replace(arguments.callee.sRE, '\\$1');
}
function verifySMS(field) {
	var removedChars = "";
	var text = field.value;
	for(i = 0; i < text.length; ++i) {
		code = text.charCodeAt(i);
		charact = text.substring(i,i+1);
		if(code==8216 || code==8217) {
			//Curly single quotes
			text = text.replace(new RegExp(escapeRegex(charact),"g"), "'");
		}
		else if(code==8220 || code==8221) {
			//Curly double quotes
			text = text.replace(new RegExp(escapeRegex(charact),"g"), "\"");
		}
		else if(code==8230) {
			//... as a single character
			if(text.length+2>160) {
				text = text.replace(new RegExp(escapeRegex(charact),"g"), ".");
			}
			else {
				text = text.replace(new RegExp(escapeRegex(charact),"g"), "...");
				i+=2;
			}
		}
		else if(code < 32 || code > 122 || code==91 || code==92 || code==93 || code==94 || code==96) {
			text = text.replace(new RegExp(escapeRegex(charact),"g"), "");
			removedChars = removedChars + charact;
			i--;
		}
	}
	field.value=text;
//	if (removedChars != "")
//	alert("Your entry has been slightly reformatted to be easier to read by the folks who read your application. Please just give it another read-through to make sure you're happy with it!", function() { return true; });
	if(window.setCounters) {
		setCounters();
        } else if (window.updateCounters) {
                updateCounters();
        }
}
