(function($){
	$.extend({
		tablesorterColumnfilter: new function() {
			this.defaults = {};
			this.construct = function(settings) {
				return this.each(function() {
					config = $.extend(this.config, $.tablesorterColumnfilter.defaults, settings);
					var table = this;
					// strip out 'other' string and replace option value with option text
					$('.column-filters').find('select').each(function(index) {
						var $select = $(this);
						$('option', $select).each(function(i){
							if ($(this).text().toLowerCase() == 'other') {
								$(this).remove();
							} else if (i == 0) {
								// do nothing								
							} else {
								$(this).val($(this).text());
							}
						});
					});
				});
			}
		}
	});
	// extend plugin scope
	$.fn.extend({
        tablesorterColumnfilter: $.tablesorterColumnfilter.construct
	});
})(jQuery);

/**
 * Filter function used in tablesorterFilter
 */
function has_select(str, words, caseSensitive)
{
	var text = caseSensitive ? str : str.toLowerCase();
	var phrase = caseSensitive ? words.join(' ') : words.join(' ').toLowerCase();
	if (text != phrase) return false;
	return true;
}
/**
 * Check whether a value exists in the array
 */
function in_array(needle,haystack,argStrict)
{
	var key='', strict= !!argStrict;
	if(strict) {
		for(key in haystack) {
			if (haystack[key] === needle) {
				return true;
			}
		}
	} else {
		for (key in haystack) { 
			if (haystack[key] == needle) {
				return true;
			}
		}
	}
	return false;
}

