Move directory JS to a separate file in preparation for AJAX