javascript base for switching contexts in a one page app