Generalised code to switch between side menus