refactored trails javascript and condensed into one file.