/*  Copyright Info

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    In other words, feel free to use this as you wish.  Some kind of
    attribution would be nice, but the important thing is that the
    program is useful.

    Original author: Brian Rock
    Author's Website: http://www.earn-web-cash.com
*/

cleanText = function () {
  var newTxt = new String(document.getElementById('dirty-text').value);
  var trim = new Array("\n");
  var randString = 'st7ju8UC9CaPreBa';

  var toTrim = new RegExp("\n\n", "g");
  newTxt = newTxt.replace(toTrim, randString);  
  
  toTrim = new RegExp("\n", "g");
  newTxt = newTxt.replace(toTrim, ' ');

  toTrim = new RegExp("st7ju8UC9CaPreBa", "g");
  newTxt = newTxt.replace(toTrim, "\n\n");

  document.getElementById('clean-text').value = newTxt;
}

