$(document).ready(function() {

    var months = {};
    months["JAN"] = "01";
    months["FEB"] = "02";
    months["MAR"] = "03";
    months["APR"] = "04";
    months["MAY"] = "05";
    months["JUN"] = "06";
    months["JUL"] = "07";
    months["AUG"] = "08";
    months["SEP"] = "09";
    months["OCT"] = "10";
    months["NOV"] = "11";
    months["DEC"] = "12";

    $.tablesorter.addParser({
        id: 'AlphaNum',
        is: function(s) {
            return false;
        },
        format: function(s) {
            s = '' + s;
            s = s.toUpperCase();
            if (isNaN(s)) {
                return 'ZZ' + s;
            }
            else {
                return 'AA' + PadString(s, '00000000');
            }
        },
        type: 'text'
    });

    $.tablesorter.addParser({
        id: 'DD MMM YY',
        is: function(s) {
            return false;
        },
        format: function(s) {
            s = '' + s; //Make sure it's a string 
            var hit = s.match(/(\d{2}) ([A-Za-z]{3}) (\d{2})/);
            if (hit && hit.length == 4) {
                return hit[3] + months[hit[2].toUpperCase()] + hit[1];
            }
            else {
                return s;
            }
        },
        type: 'text'
    });

    $(".option_table").tablesorter(
        {
            headers:
            {
                0: { sorter: "DD MMM YY" },
                2: { sorter: "integer" },
                4: { sorter: "currency" },
                5: { sorter: "currency" },
                6: { sorter: false }
            },

            sortClassAsc: 'headerSortUp',
            sortClassDesc: 'headerSortDown',
            
            widgets: ['zebra'],
            widgetZebra: { css: ["row_1", "row_2"] },

            sortList: [[0, 0]]
        }
    );
}
); 