jQuery.fn.liveUpdate = function(list){
	list = jQuery(list);

	if ( list.length ) {
		var highlighted = false;
		var rows = list.find('.filterable').children("a");
		var cache = rows.map(function(){
				return this.innerHTML.toLowerCase();
			});
			
		this
			.keyup(filter).keyup()
			.parents('form').submit(function(){
				return false;
			});
	}
		
	return this;
		
	function filter(){
		var term = jQuery.trim( jQuery(this).val().toLowerCase() ), scores = [];
		if (term.length > 2)
		{		
			if ( !term ) {
				rows.parent().parent(":hidden").show();
				$('.filterable').removeHighlight();			
			} else {
				rows.parent().parent(":visible").hide();

				cache.each(function(i){
					var score = this.score(term);
					if (score > 0) { scores.push([score, i]); }
				});
				$('.filterable').removeHighlight();
				$('.filterable').highlight(term);
				highlighted = true;
				jQuery.each(scores.sort(function(a, b){return b[0] - a[0];}), function(){
					jQuery(rows[ this[1] ]).parent().parent().show();
				});
			}
		}
		else if (highlighted)
		{
			rows.parent().parent(":hidden").show();
			$('.filterable').removeHighlight();
			highlighted = false;
		}
	}
};

