//  Author: Samuel Reynolds
//	Find and replace a string in another string, with optional case-sensitivity.
function ReplaceAll( inText, inFindStr, inReplStr, inCaseSensitive ) {
   //	inText is the text in which to do the search;
   //	inFindStr is the string to find;
   //	inReplStr is the string to substitute into inText in place of inFindStr; and
   //	inCaseSensitive is a boolean value (defaults to false).
   
   var searchFrom = 0;
   var offset = 0;
   var outText = "";
   var searchText = "";
   if ( inCaseSensitive == null ) {
      inCaseSensitive = false;
   }
   if ( inCaseSensitive ) {
      searchText = inText.toLowerCase();
      inFindStr = inFindStr.toLowerCase();
   } else {
      searchText = inText;
   }
   offset = searchText.indexOf( inFindStr, searchFrom );
   while ( offset != -1 ) {
      outText += inText.substring( searchFrom, offset );
      outText += inReplStr;
      searchFrom = offset + inFindStr.length;
      offset = searchText.indexOf( inFindStr, searchFrom );
   }
   outText += inText.substring( searchFrom, inText.length );
   
   return ( outText );
};

function QuoteHtml( inText ) 
{ var outText = ReplaceAll( inText, "&", "&amp;" ); 
  outText = ReplaceAll( outText, "<", "&lt;" ); 
  outText = ReplaceAll( outText, ">", "&gt;" ); 
  outText = ReplaceAll( outText, '"', "&quot;" ); 
  outText = ReplaceAll( outText, "\n", "<br />" ); 
  return ( outText ); 
} 