Electronic surface resonances and the thermally induced W(001) structure transition