﻿function AddSortColumn(repeaterId, parentName, columnsorted, columnsortedType) {
    
    if (columnsorted != null)
    { columnsorted = columnsorted.toLowerCase(); }
    $('#' + parentName + ' thead tr th, thead tr td, tr.cssGridHeader td,tr.cssGridHeader th').each(function(i) {
        var cell = $(this);
        var sortItem = cell.attr("sortItem");
        if (sortItem != null) {
        
            cell.addClass("Sortheader");
            sortItem = sortItem.toLowerCase();
            if (sortItem == columnsorted) {

                cell.attr("sortType", columnsortedType);

                if (columnsortedType == 1) {
                    cell.addClass("headerSortUp");
                }
                if (columnsortedType == 0)
                { cell.addClass("headerSortDown"); }

            }

            cell.click(function() {


                var sortType = cell.attr("sortType");

                if (sortType != null) {
                    sortType = 0;
                }
                if (columnsortedType != null) {
                    sortType = columnsortedType;
                }

                __doPostBack(repeaterId, sortItem + ',' + sortType);
            });
        }

    });
}
function FreezeGridViewHeader(gridID, wrapperDivCssClass) {

    var grid = document.getElementById(gridID);
    if (grid != 'undefined') {
        grid.style.visibility = 'hidden';
        var div = null;
        if (grid.parentNode != 'undefined') {
            //Find wrapper div output by GridView
            div = grid.parentNode;
            if (div.tagName == "DIV") {
                div.className = wrapperDivCssClass;
                div.style.overflow = "auto";
            }
        }

        var tags = grid.getElementsByTagName('TBODY');
        if (tags != 'undefined') {
            var tbody = tags[0];
            var trs = tbody.getElementsByTagName('TR');
            var headerHeight = 8;
            if (trs != 'undefined') {
                headerHeight += trs[0].offsetHeight;
                var headTR = tbody.removeChild(trs[0]);
                var head = document.createElement('THEAD');
                head.appendChild(headTR);
                grid.insertBefore(head, grid.firstChild);
            }
            //Needed for Firefox
            tbody.style.height =
                  (div.offsetHeight - headerHeight) + 'px';
            tbody.style.overflowX = "hidden";
            tbody.overflow = 'auto';
            tbody.overflowX = 'hidden';
        }
        grid.style.visibility = 'visible';
    }
}
       
            
    

