/*
 *
 * TableSorter 2.0 Parser for recognition and sorting of 'day of week' Columns
 * Version 2.0.3
 * @requires jQuery v1.2.3
 * @requires jQuery.tablesorter v2.0
 *
 * Copyright (c) 2008 Björn Mönikes
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */


$.tablesorter.addParser( {
    // set a unique id
    id: "dayparser",
    is: function(s) {
	// check, if column contains abbreviation for day of week
    var result = s.match(new RegExp("/^(Mo|Di|Mi|Do|Fr|Sa|So)$/"));
    if (result == null)
        return false;
	else return (  result.length > 0 ? true : false  );
    },
    format: function(s) {
	// format data for normalizaion
	return s.toLowerCase().replace(/mo/,1).replace(/di/,2).replace(/mi/,3).replace(/do/,4).replace(/fr/,5).replace(/sa/,6).replace(/so/,7)
    },
    type: "numeric"
});

$.tablesorter.addParser({
    id: "currency2",
    is: function(s) {
      return /[£$€?.]$/.test(s);
    },
    format: function(s) {
      s = s.replace(/\./,"").replace(/,/,".");
      return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""));
    },
    type: "numeric"
  });

$.tablesorter.addParser({
    id: "category",
    is: function(s) {
      return (/^\d\+*$/).test(s);
    },
    format: function(s) {
      return category2value(s);
    },
    type: "numeric"
  });


$.tablesorter.addParser({
  id: "euroDate",
  is: function(s) {
      return (/\d{1,2}\.\d{1,2}\.\d{4}$/).test(s);
  },
  format: function(s) {   
    var parts = s.split(".");
    var t = new Date(parts[2],parts[1],parts[0]).getTime();
    return $.tablesorter.formatFloat(t);
  },
  type: "numeric"
});


$.tablesorter.addParser({
    id: "minidate",
    is: function(s) {
      return (/\d{1,2}\.\d{1,2}\.$/).test(s);
    },
    format: function(s,table) {
      s = s.split(".");
      var today = sysDate.split(".");
      s[2] = today[2];
      if (parseInt(s[1]) < parseInt(today[1]))
        s[2] = parseInt(s[2]) +1;
      return (new Date(parseInt(s[2]),parseInt(s[1])-1,parseInt(s[0])).getTime());
    },
    type: "numeric"
  });  