From http://www.webtoolkit.info/javascript-url-decode-encode.html