add server down handling

move more js libs into layout.
add socket init in separate file.
add re-login when server restarted
add server down page