        jQuery.expr[":"].containsNoCase = function(el, i, m) {
            var search = m[3];
            if (!search) return false;
            return eval("/" + search + "/i").test($(el).text());
        };

        jQuery(document).ready(function() {
            jQuery('#farmersMarket tr').hide();

		// Show All  (currently not being used)
		$('#showAll').click(function() {
  		$('#farmersMarket tr').show('slow', function() {
    		// Animation complete.
  		});
		});

            // hide the cancel search image
            jQuery('#imgSearch').hide();

            // reset the search when the cancel image is clicked
            jQuery('#imgSearch').click(function() {
                resetSearch();
            });

            // cancel the search if the user presses the ESC key
            jQuery('#txtSearch').keyup(function(event) {
                if (event.keyCode == 27) {
                resetSearch();
                }
            });

            // cancel the search if the user presses the BACKSPACE key
            jQuery('#txtSearch').keyup(function(event) {
                if (event.keyCode == 8) {
            		jQuery('.norecords').remove();
                }
            });

            // cancel the search if the user HIGHLIGHTS TEXT
		//jQuery('#txtSearch').focus(function() {
		//	$(this).select();
               	//}
                	//resetSearch();
            //});

            // execute the search
            jQuery('#txtSearch').keyup(function() {
                // only search when there are 4 or more characters in the textbox
                if (jQuery('#txtSearch').val().length > 3) {
        		// hide all rows 
			jQuery('#farmersMarket tr').hide();
                    	// show the header row
                    	jQuery('#farmersMarket tr:first').show();
                    	// show the matching rows (using the containsNoCase from Rick Strahl)
                    	jQuery('#farmersMarket tr td:containsNoCase(\'' + jQuery('#txtSearch').val() + '\')').parent().show();
                    	// show the cancel search image
                    	jQuery('#imgSearch').show();
                }

                else if (jQuery('#txtSearch').val().length == 0) {
                    // if the user removed all of the text, reset the search
                    resetSearch();
                }

                // if there were no matching rows, tell the user
                if (jQuery('#farmersMarket tr:visible').length == 1) {
                    // remove the norecords row if it already exists
                    jQuery('.norecords').remove();
                    // add the norecords row
                    jQuery('#error').append('<span class="norecords">No records were found.</span>');
                    jQuery('#farmersMarket tr:first').hide();
                }
            });
        });

        function resetSearch() {
            // clear the textbox
            jQuery('#txtSearch').val('');
            // hide  all table rows
             jQuery('#farmersMarket tr').hide();
            // remove any no records rows
            jQuery('.norecords').remove();
            // remove the cancel search image
            jQuery('#imgSearch').hide();
            // make sure we re-focus on the textbox for usability
            jQuery('#txtSearch').focus();
        }

