var trim = function( str ){ return (typeof str=='string')?str.replace(/^[\s\n\r]+/,'').replace(/[\s\n\r]+$/,''):str; };