var count=1; 
function showhide(id){
if (document.getElementById){
obj = document.getElementById(id);
if (obj.style.display == "none"){
obj.style.display = "inline";
} else {
obj.style.display = "none";
}
}
}

function roll(id,max,dir){
showhide(id+count);
count+=dir;
if (count==max+1) count=1;
if (count==0) count=max;
showhide(id+count);
}