Parse URL using snippet from here: http://james.padolsey.com/javascript/parsing-urls-with-the-dom/