Thermoelectric and thermospin switch realized by a three-terminal nanojunction