$(function() {
    /* -------------------------------------------------------------- */
    /*  Confirm Item Deletion
    /* -------------------------------------------------------------- */
    $('.delete-item').click(function() {
        var answer = confirm("Delete this item?")
        if (answer){
            return true;
        }
        else{
            return false;
        };
    });
    

});

/* -------------------------------------------------------------- */
/*  AutoCompleters
/* -------------------------------------------------------------- */
function lookup(inputString) {
    if(inputString.length == 0) {
        // Hide the suggestion box.
        $('#suggestions').hide();
    } else {
        $.post("rpc.php", {queryString: ""+inputString+""}, function(data){
            if(data.length >0) {
                $('#suggestions').show();
                $('#autoSuggestionsList').html(data);
            }
        });
    }
}//lookup

function fill(id, value) {
    $('#inputId').val(id);
    $('#inputString').val(value);
    $('#suggestions').hide();
}//fill

function beerBrandLookup(inputString) {
    if(inputString.length == 0) {
        $('#suggestions').hide();   // Hide the suggestion box.
    } else {
        $.post("beerBrands-rpc.php", {queryString: ""+inputString+""}, function(data){
            if(data.length >0) {
                $('#suggestions').show();
                $('#autoSuggestionsList').html(data);
            } else {
                $('#suggestions').hide();
            }
        });
    }
}

function fillBeerBrand(id, value) {
    $('#beerBrandId').val(id);
    $('#inputString').val(value);
    $('#suggestions').hide();
    BrandChange();
}//fill

