Put reorder menu JS into a function