function cleanUpMSWordCharacters(){
	if ( document.forms[0] ){
		var oldOnsubmit = (document.forms[0].onsubmit) ? document.forms[0].onsubmit : function(){};
		document.forms[0].onsubmit = function(){doCleanUp();oldOnsubmit();}
	}
}

// @namespace     http://diveintogreasemonkey.org/download/
// @description   straighten curly quotes and apostrophes, simplify fancy dashes, etc.
// @include       *
// ==/UserScript==
function doCleanUp(){
	var replacements, regex, key, textnodes, node, s;
	
	replacements = {
	    "\xa0": " ",
	    "\xa9": "(c)",
	    "\xae": "(r)",
	    "\xb7": "*",
	    "\u2018": "'",
	    "\u2019": "'",
	    "\u201c": '"',
	    "\u201d": '"',
	    "\u2026": "...",
	    "\u2002": " ",
	    "\u2003": " ",
	    "\u2009": " ",
	    "\u2013": "-",
	    "\u2014": "--",
	    "\u2122": "(tm)",
	    "\u2022": "*",
	    "<br/>" : "<br>",
	    "<br />" : "<br>"};
	regex = {};
	for (key in replacements) {
	    regex[key] = new RegExp(key, 'g');
	}
	
	var textnodes = document.getElementsByTagName('textarea');
	if ( textnodes ) {
		for ( i = 0; i < textnodes.length; ++i ){
			var oTextArea = textnodes[i];
			var oText = textnodes[i].value;
			if ( oText ) {
				for ( key in replacements ) {
					oText = oText.replace(regex[key], replacements[key]);
				}
				textnodes[i].value = oText;
			}
		}
	}
}


// ===========================================================================
// clean up strange characters in textareas as part of the window.onload event
// ===========================================================================
var oldOnload = (window.onload) ? window.onload : function(){};
window.onload = function(){cleanUpMSWordCharacters();oldOnload();}