var WordCleaner = function()
{
	/**
	 * The DOM element to get the input from
	 * @access protected
	 */
	this.elem_input = null;
	
	/**
	 * The DOM element to get the output from
	 * @access protected
	 */
	this.elem_output = null;
	
	/**
	 * The array of MS Word characters to find for replacement
	 * @access protected
	 */
	this.arr_find = [
		String.fromCharCode(8220), //“
		String.fromCharCode(8221), //”
		String.fromCharCode(8216), //‘
		String.fromCharCode(8217), //‘
		String.fromCharCode(8211), //–
		String.fromCharCode(8212), //—
		String.fromCharCode(189), //½
		String.fromCharCode(188), //¼
		String.fromCharCode(190), //¾
		String.fromCharCode(169), //©
		String.fromCharCode(174), //®
		String.fromCharCode(8230), //…
		String.fromCharCode(13),
		"&#61607;"
	];
	
	/**
	 * The array of standard string to replace MS Word characters in this.arr_find with
	 * @access protected
	 */
	this.arr_replace = [
		'"',
		'"',
		"'",
		"'",
		"-",
		"--",
		"1/2",
		"1/4",
		"3/4",
		"&#169",
		"&#174",
		"...",
		"<br>",
		"-"
	];
	
	/**
	 * This is where the magic happens.  Give it a string and it will output 
	 * the scrubbed string.  You can call statically from WordCleaner.scrub()
	 *
	 * @access public
	 * @param input_string		- The string to be scrubbed
	 * @return string
	 */
	this.scrub = function(input_string)
	{		
		//Make sure find and replace have equal lengths
		if ( !(this.arr_find.length == this.arr_replace.length) ) {
			throw new Error("The MS Word entities find values do not match the replacement values");
			
		}
		
		//Still here, then replacement rules are ok - loop across and do the replacement
		for ( var i=0; i<this.arr_find.length; i++ ) {
			var regex = new RegExp(this.arr_find[i], "gi");
			input_string = input_string.replace(regex, this.arr_replace[i]);
			
		}//for
		
		//Still here, then replacement rules are ok - loop across and do the replacement
		for ( var i=0; i<this.arr_find.length; i++ ) {
			var regex = new RegExp(this.arr_find[i], "gi");
			input_string = input_string.replace(regex, this.arr_replace[i]);
			
		}//for		
		
		if(!document.all){
		//	input_string = input_string.replace(/\r|\n|\r\n/g, "<br>");
		}
		
		//Put the cleaned string into the output box								
		return input_string
		
	}//end scrub
	
}//end WordCleaner

/**
 * Just a little bit of a hack to get WordCleaner.scrub() to work as a 
 * "static" method as well as a method on an instance object...
 */
WordCleaner.scrub = function(input_string)
{
	var obj = new WordCleaner();
	return obj.scrub(input_string);
	
}//end WordCleaner.scrub
