﻿$.tablesorter.addParser({
    id: 'handicap',
    is: function (s) {
        return false;
    },
    format: function (s) {
        return s.replace('+', '-').replace('Pending', '99');
    },
    // set type, either numeric or text 
    type: 'numeric'
});

$.tablesorter.addParser({
    id: 'topar',
    is: function (s) {
        return false;
    },
    format: function (s) {
        s = s.replace(/<[^>]*?>/, '');
        if (s == '') s = '99999';
        if (s == '-') s = '99999';
        if (s == 'DQ') s = '99999';
        if (s == 'WD') s = '99999';
        return s.replace('Ev', '0');
    },
    // set type, either numeric or text 
    type: 'numeric'
});

$.tablesorter.addParser({
    id: 'updown',
    is: function (s) {
        return false;
    },
    format: function (s) {
        if (s == '-') s = "0";
        var r = new RegExp(/^.*?[<][!][-][-]\s([-]?\d+)\s/);
        var x = r.exec(s);
        if (x) return x[1];
        return s;
    },
    // set type, either numeric or text 
    type: 'numeric'
});

$(document).ready(function () {
    $('table.tablesorter').tablesorter();
    //$("table.tablesorter").tablesorter({ headers: { 2: { sorter: 'handicap'}} });
});
