var max = 1;
aus = setTimeout("onoff(0)",500);

function onoff(nr) {

clearTimeout(aus);

if(nr > max) max = nr;
for(i = 1; i <= max; i ++) {
  document.getElementById("m"+i).style.visibility="hidden";
}
if(nr != 0) {
  document.getElementById("m"+nr).style.visibility="visible";
}
aus = setTimeout("onoff(0)",4000);
}
