﻿// JScript File
<!--
function scrubText() {
    oInputs = document.getElementsByTagName( 'input' ) // store collection of all <input/> elements
    for ( i = 0; i < oInputs.length; i++ ) { // loop through and find <input type="text"/>
        if ( oInputs[i].type == 'text' || oInputs[i].type == 'password') {
            oInputs[i].value = htmlEncode(oInputs[i].value); // Update the value with the HTML encoding
        }
    }
    oTextareas = document.getElementsByTagName( 'textarea' ) // store collection of all <textarea/> elements
    for ( i = 0; i < oTextareas.length; i++ ) { // loop through each element
        oTextareas[i].value = htmlEncode(oTextareas[i].value); // Update the value with the HTML encoding
    }
}

function htmlEncode(s) {
        var str = new String(s);
        
        str = str.replace(/</g, "&lt;"); 
        
        str = str.replace(/&#8220;/g, '\"'); 
        str = str.replace(/&#8221;/g, '\"'); 
        str = str.replace(/&#34;/g, '\"'); 

		str = str.replace(/&#8216;/g, "'");
		str = str.replace(/&#8217;/g, "'");

		str = str.replace(/&#8242;/g, "'"); 
		str = str.replace(/&#8243;/g, '\"'); 

		str = str.replace(/&#/g, "& #"); 

        return str;
             
} 
//-->
