Some javascript for changing phase