Remove absolute url locations for portability

Detect current window.location to find base URL for ajax, etc resources.
This makes it easier to relocate the code.