/*
        The following JavaScript Object is used to test the callback functionality for both
        the tableSort & pagination scripts. It calculates the average rating for the rows
        "currently visible" on screen and updates the appropriate table cell with the new value.
        
        Additionally, the method "displayTextInfo" is used by the pagination script to display
        the current page number etc.
*/
var callbackTest = {
        
        displayTextInfo:function(opts) {
                if(!("currentPage" in opts)) { return; }
                
                var p = document.createElement('p'),
                    t = document.getElementById('theTable-fdtablePaginaterWrapTop'),
                    b = document.getElementById('theTable-fdtablePaginaterWrapBottom');
                
                p.className = "paginationText";    
                p.appendChild(document.createTextNode("Page " + opts.currentPage + " de " + Math.ceil(opts.totalRows / opts.rowsPerPage)));
                
                t.insertBefore(p.cloneNode(true), t.firstChild);
                b.appendChild(p);


var tablesort = document.getElementById("theTable");
var x = tablesort.className.match(/startpage-([0-9]+)/)[1];
tablesort.className = tablesort.className.replace("startpage-" + x,"startpage-" + opts.currentPage);
setPageNumberCookie();

        }
};
