function showZipDialog(callback) {
    var zipSubmitter = function(event) { event.preventDefault();doZipCheck(callback) };
    $("#zdSubmitter").unbind().click(zipSubmitter);
    $("#zipDialog").jqmShow();
    $("#zipPromptValue").unbind().keyup(function(event) {
        if (event.which == 13) {
            event.stopPropagation();
            doZipCheck(callback);
        }
        else if (/\D/.test($("#zipPromptValue").val())) {
            $("#zdError").text("Please enter numbers only").css({display:'inline'});
        }
        else {
            $("#zdError").hide();
        }
    }).val("")[0].focus();
}

function closeZipDialog() {
    $("#zdError").hide();
    $('#zipDialog').jqmHide();
}

function doZipCheck(callback) {
    if (/[0-9]{5}/.test($("#zipPromptValue").val())) {
        $.get("/go/includes/_zipValid.jsp", {'zc': $("#zipPromptValue").val()}, function(data) {
            if (eval(data)) {  //Call returns a string, either "true" or "false"
                $("#zipDialog").jqmHide();
                callback.call(window, $("#zipPromptValue").val());
            }
            else {
                $("#zipPromptValue").val('');
                $("#zdError").html("We could not recognize the ZIP code you entered.<br>Please enter a valid ZIP code and try again.").css({display:'block'});
            }
        });
        }
    else {
        $("#zdError").text("Please enter a valid five-digit ZIP code").css({display:'inline'});
    }
}

function doTrimlistOpen(url) {
    var trimPop = window.open(url, "trimlistPop","width=590,height=400,left=200,top=200,scrollbars,resizable");
    /*if (trimPop == null || typeof trimPop == "undefined") {
        alert("Your popup-blocker settings are preventing us from completing your request.\nPlease add Cars.com to your allowed sites to continue.");
    }*/
}