if(!window.jQuery) alert("LetterBlock Filter requires jQuery, which seems to be missing. If you're a visitor, try refreshing the page and/or complaining to the site operator. If you are the site operator, get with the program.");
window.LB || (LB={});
LB.filter = function($,pub){ return pub = {
	innerText: function(e) {
		if(e.textContent) return e.textContent;
		if(e.innerText) return e.innerText;
		var str='';
		var cn = e.childNodes;
		for(var i=0; i<cn.length; i++)
		{
			if(cn[i].nodeType==3) str += cn[i].nodeValue;
			if(cn[i].nodeType==1) str += arguments.callee(cn[i]);
		}
		return str;
	},
	init: function(input,container,extract) {
		/* input: jQuery query string pointing to the <input type="text" /> to use
		 * extract (optional): function to extract text to be searched from an element passed as its sole argument. defaults to LB.filter.innerText */
		extract || (extract = pub.innerText); 
		$(function(){
			input = $(input);
			container = $(container).get(0);
			var tlist = container.childNodes; var list = [];
			for(var i=0; i<tlist.length; i++) if(tlist[i].nodeType==1) list[list.length] = tlist[i];
			input.keyup(function(e){
				var needle = this.value.toLowerCase();
				var found = 0;
				var doFilter = function(item) {
					var text = item._lbFilterText!=undefined ? item._lbFilterText : (item._lbFilterText = extract(item).toLowerCase());
					item.style.display = (!needle || text.indexOf(needle)>-1) ? (++found,''):'none';
				};
				for(var i = 0; i<list.length; i++) doFilter(list[i]);
				$(this)[found ? 'removeClass':'addClass']('no-match')[found&&needle ? 'addClass':'removeClass']('match');
				input.trigger('lbfilter',[{found:found,search:needle}]);
			}).keyup();
		});	
	}
};}(jQuery);