// used on about-us/faculty-staff/index.aspx

$(document).ready(function() { 
    // extend the default setting to always include the zebra widget. 
    $.tablesorter.defaults.widgets = ['zebra']; 
    // extend the default setting to always sort on the first column 
    $.tablesorter.defaults.sortList = [[0,0]]; 
    // call the tablesorter plugin 
    $("#directory").tablesorter(); 
}); 


$(function() {
	//overrides CSS display:none property so only users w/ JS will see the filter box
	$('.DirectorySearch').show().removeClass("hidden none");
	
	// CUSTOMIZE THE FOLLOWING LINE: What are you filtering?
	var filterTR = "table#directory tbody tr";
	
	$("#DirectorySearch").keyup(function(event) {
	//if esc is pressed or nothing is entered
	if (event.keyCode == 27 || $(this).val() == "") {
		//if esc is pressed we want to clear the value of search box
		$(this).val("");
		//we want each row to be visible because if nothing is entered then all rows are matched.
		$(filterTR).show();
	} else {
		filter(filterTR, $(this).val());
		}
	});
	
	function filter(selector, query) {
	query = $.trim(query); //trim white space
	query = query.replace(/ /gi, '|'); //add OR for regex
	
	$(selector).each(function() {
		($(this).text().search(new RegExp(query, "i")) < 0) ? $(this).hide() : $(this).show();
	});

	// tablesorter zebra widget from above 
	$.tablesorter.defaults.widgets = ['zebra']; 
	$("#directory").tablesorter();  
	}
});