encodeURI function is built-in function.
http://www.w3schools.com/jsref/jsref_obj_global.asp