/**

 * marks all rows and selects its first checkbox inside the given element

 * the given element is usaly a table or a div containing the table or tables

 *

 * @param    container    DOM element

 */

var marked_row = new Array;

function markAllRows( container_id ) {

    var rows = document.getElementById(container_id).getElementsByTagName('tr');

    var unique_id;

    var checkbox;



    for ( var i = 0; i < rows.length; i++ ) {



        checkbox = rows[i].getElementsByTagName( 'input' )[0];



        if ( checkbox && checkbox.type == 'checkbox' ) {

            unique_id = checkbox.name + checkbox.value;

            if ( checkbox.disabled == false ) {

                checkbox.checked = true;

                if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {

                    rows[i].className += ' marked';

                    marked_row[unique_id] = true;

                }

            }

        }

    }



    return true;

}



/**

 * marks all rows and selects its first checkbox inside the given element

 * the given element is usaly a table or a div containing the table or tables

 *

 * @param    container    DOM element

 */

function unMarkAllRows( container_id ) {

    var rows = document.getElementById(container_id).getElementsByTagName('tr');

    var unique_id;

    var checkbox;



    for ( var i = 0; i < rows.length; i++ ) {



        checkbox = rows[i].getElementsByTagName( 'input' )[0];



        if ( checkbox && checkbox.type == 'checkbox' ) {

            unique_id = checkbox.name + checkbox.value;

            checkbox.checked = false;

            rows[i].className = rows[i].className.replace(' marked', '');

            marked_row[unique_id] = false;

        }

    }



    return true;

}