javascript for view switching now working