Resolve error where parsed_url was being referenced but not declared

`parsed_url` was being used in a function call yet the variable did not exist.  Additionally, the function being called was getting referenced before it was declared.
Merge pull request #7 from borkweb/fix-js-error

Resolve error where parsed_url was being referenced but not declared