Or
// it does output an undefined at the end of each group
var content_in_group = 0;
var groups = 0;
// can only run once^
var group1 = ["a", "b", "d"];
var group2 = ["ae", "be", "de", "ttt"];
var group3 = ["ar", "br", "dr"];
var group_ids = [group1, group2, group3];
var i = (group_ids[groups])[content_in_group];
content_in_group = content_in_group + 1;
if (i == undefined) {
content_in_group = 0;
groups = groups + 1;
}
if (group_ids[groups] == undefined) {
content_in_group = 0;
groups = 0;