replace deprecated escape() and unescape() functions

instead using encodeURIComponent() and decodeURIComponent()