// The following from:
// https://lists.latech.edu/pipermail/javascript/2004-May/007575.html
// liorean@f2o.org 

String.prototype.trim=function(){
     var
         r=/^\s+|\s+$/g,
         a=this.split(/\n/g),
         i=a.length;
     while(i-->0)
         a[i]=a[i].replace(r,'');
     return a.join('\n');
}
