put the anchor linking for both links and window.location.hash in one function