
// custom parser to sort edition numbers (ex: 6e, 21e) like numbers, by removing the 'e'
// voir http://stackoverflow.com/questions/450936/using-jquery-tablesorter-to-sort-mm-yy-dates for details
jQuery.tablesorter.addParser({
		// set a unique id
		id: 'user-edition',
		is: function(s) {
				// return false so this parser is not auto detected
				return false;
		},
		format: function(s, table, cell) {
				// format your data for normalization
				if ( s == '' ) return( 0 );
				return s.replace(/re/,'').replace(/er/,'').replace(/e/,'');
		},
		// set type, either numeric or text
		type: 'numeric'
});

jQuery.tablesorter.addParser({
		// set a unique id
		id: 'user-date',
		is: function(s, table, cell) {
				// return false so this parser is not auto detected
				return false;
		},
		format: function(s, table, cell) {
				// format your data for normalization
				return s.replace(/à venir/,'9999-99-99');
		},
		// set type, either numeric or text
		type: 'text'
});

jQuery.tablesorter.addParser({
		// set a unique id
		id: 'rel-date',
		is: function(s, table, cell) {
				// return false so this parser is not auto detected
				return false;
		},
		format: function(s, table, cell) {
				// format your data for normalization
				var date = jQuery(cell).attr('rel');  // get date in yyyy-mm-dd format that we stored in the cell's rel attribute
				if ( date == "0000-00-00" ) return( '9999-99-99' ); // put unknown dates at the end for now
				return date;
		},
		// set type, either numeric or text
		type: 'text'
});

jQuery.tablesorter.addParser({
		// set a unique id
		id: 'circuit-niveau',
		is: function(s) {
				// return false so this parser is not auto detected
				return false;
		},
		format: function(s, table, cell) {
				// format your data for normalization
				if ( s == '' ) return( 9 );
				return s.replace(/National/,'0').replace(/Provincial/,'1').replace(/Regional/,'2').replace(/Local/,'5');
		},
		// set type, either numeric or text
		type: 'numeric'
});

// add new widget to perform row nighlithing upon hover
jQuery.tablesorter.addWidget({
	// give the widget a id
	id: "hiliterow",
	// format is called when the on init and when a sorting has finished
	format: function(table) {
		jQuery('tbody tr').hover(function(){
		  jQuery(this).addClass('hovered');
		}, function(){
		  jQuery(this).removeClass('hovered');
		});
	}
});

jQuery.tablesorter.addWidget({
	// give the widget a id
	id: "hiliteheader",
	// format is called when the on init and when a sorting has finished
	format: function(table) {
		jQuery('thead tr th').hover(function(){
		  jQuery(this).addClass('hovered');
		}, function(){
		  jQuery(this).removeClass('hovered');
		});
	}
});



// add new widget called setup popinfo link
/***
jQuery.tablesorter.addWidget({
	// give the widget a id
	id: "popupinfolink",
	// format is called when the on init and when a sorting has finished
	format: function(table) {
				
		// this activates the fancybox effect on the link that allows the user to access details for each event
		jQuery(".popupinfo").fancybox({
			'hideOnContentClick': false,
			'zoomOpacity': true,
			'zoomSpeedIn':		300, 
			'zoomSpeedOut':	300, 
			'frameWidth': 800,
			'frameHeight': 500,
			'overlayShow':		false
		});
				
	}
});
****/
