var g_recDurationTable = new MyTable("recordDurationTable", [0, 1]);

function initializeRecDurationTable()
{
    g_recDurationTable.initialize(new Array("Disk Size (GB)", "Video Quality",
        "Hours", "Days", "Months"));
}

function redrawRecDurationTable()
{
    var hddList;
    if (g_choice.useCustomSize && g_choice.customSize > 0) {
        hddList = new Array();
        hddList.push(g_choice.customSize);
    }
    else {
        hddList = g_choice.dev.hddList;
    }

    g_recDurationTable.empty();

    var qList = g_choice.dev.qualityList;

    var i;
    for (i = 0; i < qList.length; i++) {
        if (!g_choice.allQuality && i != g_choice.quality) {
            continue;
        }
	var bps = g_choice.calculateBitsPerSecond(i);
	var kbytesPerSecond = bps / (1000 * 8);
	var j;
        for (j = 0; j < hddList.length; j++) {
	    var hddKBytes = hddList[j] * (1000 * 1000);
	    var seconds = hddKBytes / kbytesPerSecond;
	    var hours = seconds / 3600;
	    var days = hours / 24;
	    var months = days / 30;
	    hours = Math.round(hours);
	    days = Math.round(days*10)/10;
	    months = Math.round(months*10)/10;
            var row = new MyTableRow(g_recDurationTable);
            row.cells.push(new MyTableCell(hddList[j], hddList[j]));
            row.cells.push(new MyTableCell(qList[i], i));
            row.cells.push(new MyTableCell(hours, hours));
            row.cells.push(new MyTableCell(days, days));
            row.cells.push(new MyTableCell(months, months));
            g_recDurationTable.addRow(row);
	}
    }

    g_recDurationTable.redraw();
}
