﻿// JScript File
function matchTableRowHeights(tables) {

    //function to set row heights to max rendered height found across all passed tables.
    // matches rows in order, handles different length tables.
    

    var rowidx = 0;
    var row;
    var rowheight;
    var foundrow = false;
     
    do {
        rowheight = 0;
        for (var i=0;i<tables.length;i++) {
            foundrow=false;
            
            //for this row
            //get max height across all tables
            if (i < tables.length) {
                if (tables[i]) {
                    row = tables[i].rows[rowidx];
                    
                    //get the max
                    if ((row) && (row.cells[0])){
                        foundrow=true;
                        rowheight = (rowheight < row.cells[0].clientHeight) ? row.cells[0].clientHeight : rowheight;
                    }
                }
            }            
        }
        
        //at this point, we have the max clientheight as rendered
        //now, set all rows to this height
        
        if (foundrow) {
            for (var i=0;i<tables.length;i++) {
                if (i < tables.length) {
                    if (tables[i]) {
                        row=tables[i].rows[rowidx];
                        if (row) {
                             for (var c=0;c<row.cells.length;c++) {
                             row.cells[c].height=rowheight;
                            } 
                         
                           
                        }
                    }
                }
            }
        }
        
        rowidx++;
        
    } while (foundrow)
    


}
