Problem with For loop


maxday = 30;
monthcodes = new Array(6, 2, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4);
calcday = function (currentday) {
    iyear = year-2000;
    iyear += Math.floor(iyear/4);
    correspondingcode = monthcodes[monthnum];
    iyear += correspondingcode;
    iyear += currentday;
    for (i=0; i<99; i++) {
        if (iyear>7) {
            iyear -= 7;
        } else {
            i = 5675;
        }
    }
    if (iyear == 7) {
        iyear = 0;
    }
    return iyear
};
rownum = 0;
columnnum = 0;
positionboxes = function () {
    for (i=1; i<maxday+1; i++) {
        _root["box"+i].date.text = i;
        _root["box"+i]._x = calcday(i)*110
    }
};
positionboxes();

the calcday function is just a function that calculates what day of the week and returns that in the form of a number from 0-6, where 0 = sunday, 1 = monday, etc. Nothing much to be concerned with. The real problem is inside the positionboxes function. The for loop works just fine if i remove the:

_root["box"+i]._x = calcday(i)*110

But, if I leave that peice of code inside the loop the loop will only run once. If I have ANY peice of code involving the calcday() functiion ive made, the loop will only run once. Why is the loop stopping when that happens but continues fine without it?