//var swapCodes   = new Array(8211, 8212, 8216, 8217, 8220, 8221, 8226, 8230,  0188,  0189,  0190); // mysterious substituion of "youtube" --> "yout3/4
//var swapStrings = new Array("--", "--", "'",  "'",  '"',  '"',  "*",  "...", "1/4", "1/2", "3/4");  

var swapCodes   = new Array(8211, 8212, 8216, 8217, 8220, 8221, 8226, 8230); // dec codes from char at
var swapStrings = new Array("--", "--", "'",  "'",  '"',  '"',  "*",  "...");  

function replaceWordCharacters(input){
	input.value = getCleanValue(input.value);
	return true;
}

function getCleanValue(input) {
    // debug for new codes
    // for (i = 0; i < input.length; i++)  alert("'" + input.charAt(i) + "': " + input.charCodeAt(i));
  
    var output = input;
    for (i = 0; i < swapCodes.length; i++) {
        var swapper = new RegExp("\\u" + swapCodes[i].toString(16), "g"); // hex codes
        output = output.replace(swapper, swapStrings[i]);
    }
    return output;
}

/*
 HTML use example:

<script language="Javascript">word-to-plain-text.js</script>

<form name="wordCleaner" onsubmit="return false;">
<textarea style="width: 480px; height: 100px" id="wordInput">&bull; &ldquo;Double Quotes&rdquo;,
&bull; &lsquo;Single quotes&rsquo;, 
&bull; Ellipsis &hellip;,
&bull; en-dash &ndash;</textarea><br />

<button onClick="wordInput.value = getCleanValue(wordInput.value)">Clean</button>
</form>

*/

