String.prototype.trim = function() { var x = this; x = x.replace(/^\s*(.*)/, "$1"); x = x.replace(/(.*?)\s*$/, "$1"); return x; }