Ensured that virtual directory name works and forced to use Page.url() in Javascript.
Removed trailing whitespaces. Fixed tabs and spaces mixed.