refactored the trail display code into multiple javascript files