// ===============================================================
// COLUMN FREEZE
// ===============================================================	
var COL_PFIXED = 0;
var COL_SPACES_ADD = 0;
var COL_PBORDERED = false;

function COL_FIXED_ACTIVATE()
{   
    var TAB_ACTIVE = 0;
    var COL_FIXED = COL_PFIXED;
    var BEFORE_ELEM_WIDTH = 0;
    var BEFORE_ELEM_PADDINGL = 0;
    var BEFORE_ELEM_PADDINGR = 0;
    var BEFORE_ELEM_WIDTH_TOTAL = 0;
    var BORDER = null;

    if ($(".table-tab")[0])
    {
        // For tabs
        var TAB_COUNT = $('#nav-tabContent .tab-pane').length;
        for(var tab_counter = 0; tab_counter < TAB_COUNT; tab_counter++)
        {
            var obj = ($('.tab-pane')[tab_counter]);
            if($(obj).hasClass('show'))
            {
               break;
            }
            TAB_ACTIVE++;
        }
    } 
    
    // Actual Set in Table
    for(var INDEX = 1; INDEX <= COL_FIXED; INDEX++)
    {
        if($(".div-colfix td:nth-child("+INDEX+")").css("display") != "none")
        {
            $(".div-colfix thead:nth-child("+INDEX+")").css("position", "sticky").css('left', BEFORE_ELEM_WIDTH_TOTAL+'px').css('background-color', '#006eff').css('z-index', '2');
            $(".div-colfix th:nth-child("+INDEX+")").css("position", "sticky").css('left', BEFORE_ELEM_WIDTH_TOTAL+'px').css('background-color', '#006eff').css('z-index', '2');
            $(".div-colfix td:nth-child("+INDEX+")").css("position", "sticky").css('left', BEFORE_ELEM_WIDTH_TOTAL+'px').css('background-color', '#f8f9fc').css('border-right', "2px solid #dddfeb");
            
            var class_obj = ($(".div-colfix th:nth-child("+INDEX+")")[TAB_ACTIVE]);
            BEFORE_ELEM_WIDTH =  $(class_obj).width();
            BEFORE_ELEM_PADDINGL =  $(".div-colfix th:nth-child("+INDEX+")").css('padding-left');
            BEFORE_ELEM_PADDINGR =  $(".div-colfix th:nth-child("+INDEX+")").css('padding-right');
            BEFORE_ELEM_WIDTH_TOTAL = BEFORE_ELEM_WIDTH_TOTAL + parseInt(BEFORE_ELEM_WIDTH, 10) + parseInt(BEFORE_ELEM_PADDINGL, 10) + parseInt(BEFORE_ELEM_PADDINGL, 10);
            
        }       
    }
}   

function COL_STATIC_ACTIVATE()
{
    var COL_FIXED = COL_PFIXED; 

    for(var INDEX = 1; INDEX <= COL_FIXED; INDEX++)
    {
        if($(".div-colfix td:nth-child("+INDEX+"").css("display") != "none")
        {
            // Refresh
            if($(".div-colfix td:nth-child("+INDEX+")").css("position") == "sticky")
            {
                $(".div-colfix thead:nth-child("+INDEX+")").css("position", "static");
                $(".div-colfix th:nth-child("+INDEX+")").css("position", "static");
                $(".div-colfix td:nth-child("+INDEX+")").css("position", "static");
            }
        }   
    }
}
