function wordwrap(z,Z,W,G){Z=Z||75;W=W||"\n";z=z.replace(/\r?\n/g," ");var H,j=z.split(" ");var C,a,R=0,o=0,x=0,d=[];var S=RegExp(".{"+Z+"}","g");for(C=0,a=j.length;C<a;C++){x+=j[C].length||1;if(Z<=x){x=0;if(G){H=j.slice(o,C+1).join(" ");d[R++]=H.match(S).join(W)+W+H.slice(-(H.length%Z));o=C+1,C++;continue;}d[R++]=j.slice(o,C).join(" "),o=C;}}d[R++]=j.slice(o,a).join(" ");return d.join(W);}