﻿$(document).ready(function() {
    setupTables();

    CheckDropdown();

    setupDropdown();
});

function setupTables() {

    //remove old instance of quicksearch
    $("#quicksearch").remove();

    $("#memberTable tbody tr").quicksearch({
        // I don't care for the default label text.
        labelText: '',
        inputText: 'Name/Chapter/Company',
        // Anchor the search form to the table 
        //  and position it before the table
        attached: '#quickSearchHolder',
        position: 'before',
        isFieldset: false,
        // React quickly to keypresses.
        delay: 100,

        // Eliminate the "loader".
        loaderText: '',

        //stripeRowClass: ['even', 'alt'],

        onAfter: function() {
            if ($('#listingTable tbody tr:visible').length == 0) {
                // No Items.  Do something fancy here.
            }
        }
    });
    //hide regular search box
    $("#serverSearch").hide();
}
function CheckDropdown() {
    if ($("#ctl00_MiddleContentContainer_tbSearchFilter").attr("selectedIndex") != 0) {
        $("#quicksearch").hide();
        $("#serverSearch").show();
    }
    else {
        $("#quicksearch").show();
        $("#serverSearch").hide();
    }
}
function setupDropdown() {
    $("#ctl00_MiddleContentContainer_tbSearchFilter").change(function() {

        var i = $(this).attr("selectedIndex")
        //alert(i);
        if (i != 0) {
            $("#quicksearch").hide();
            $("#serverSearch").show();
        }
        else {
            $("#quicksearch").show();
            $("#serverSearch").hide();
            //window.location = "members.aspx";
        }
    });     
}