// add parser through the tablesorter addParser method
jQuery.tablesorter.addParser({
  id: 'g_float',
  is: function(s) {
    // return false so this parser is not auto detected
    return false;
  },
  format: function(s) {
    // format your data for normalization
    return s.toLowerCase().replace(/mt/,'').replace(/,/,'').replace(/\./,'');
  },
  type: "numeric"
});

jQuery.tablesorter.addParser({
  id: 'recalc',
  is: function(s) {
    // return false so this parser is not auto detected
    return false;
  },
  format: function(s) {
	try {
		// format your data for normalization
		foo = s.toLowerCase().replace(/mt/,'').split('x', 2);
		return foo[0]*foo[1];
	} catch (err) {
		return 0;
	}
  },
  type: "numeric"
});

jQuery.tablesorter.addParser({
  id: 'first_sort',
  is: function(s) {
    // return false so this parser is not auto detected
    return false;
  },
  format: function(s) {
	try {
		// format your data for normalization
		foo = s.split(' ');
		if (foo.length > 0) return foo[0].replace(/,/,'').replace(/\./,'');
		//else return 0;
	} catch (err) {
		return 0;
	}
  },
  type: "numeric"
});

jQuery.tablesorter.addParser({
  id: 'sum_sort',
  is: function(s) {
    // return false so this parser is not auto detected
    return false;
  },
  format: function(s) {
	try {
		var sum = 0;
		// format your data for normalization
		foo = s.toLowerCase().replace(/mt/,'').split(',');
		for(var i=0; i<foo.length; i++) {
			foo1 = foo[i].split('x', 2);
			if (foo1.length != 2) continue;
			sum = sum + parseInt(foo1[0])*parseInt(foo1[1]);
		}
		return sum;
		//return foo[0]*foo[1];
	} catch (err) {
		return 0;
	}
  },
  type: "numeric"
});

