;jQuery(document).on('keyup', '[data-nxfilter-controller]', function () {
	var $ = jQuery;
	var term = $(this).val().toLowerCase();
	var filter = $(this).data('nxfilter-controller');

	// Get the list
	var list = $('[data-nxfilter-name="' + filter + '"]');

	// Show hide
	var visible = 0;
	list.each(function () {
		var value = $(this).data('nxfilter-value').toLowerCase();
		var matches = value.indexOf(term) !== -1;

		// Toggle
		visible += matches;
		$(this).toggle(matches);
	});

	// Empty message
	$('[data-nxfilter-onempty="' + filter + '"]').toggle(visible === 0);
	$('[data-nxfilter-onnotempty="' + filter + '"]').toggle(visible !== 0);
});
