code: function wordwrap( str, width, brk, cut ) {
          brk = brk || '\n';
          width = width || 75;
          cut = cut || false;
  
          if (!str) { return str; }
          var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' : '|\\S+?(\\s|$)');
  
          return str.match( new RegExp(regex, 'g') ).join( brk );
      }
docs: http://james.padolsey.com/javascript/wordwrap-for-javascript/