Updated javascript that generates the <base> element to be more sub-path friendly