potresti passare l'id come parametro della funzione:

codice:
function cambia(id) {
  mystyle = document.getElementById(id);
.
..
}
Ciao