AJS.toInit(function ($) {

    var oldColor,
        input = $("#maxSimultaneousQuickNavRequests"),
        label = $("#maxSimultaneousQuickNavRequestsLabel"),
        trigger = $("#quick_nav_off");

    $("#quick_nav_on").click(function () {
        input.removeAttr("disabled").css("color", "#000");
        label.css("color", oldColor);
        if (input.val() == 0) {
            input.val(40);
        }
    });

    trigger.click(function() {
        input.attr("disabled", "disabled").css("color", "#ccc");
        oldColor = label.css("color");
        label.css("color", "#ccc");
    });

    if (trigger.attr("checked")) {
        trigger.click();
    }

    // did you mean setting
    $("#did-you-mean-warning").hide();

    // to fix a weird FF3 bug (where it seems to carry forward or remember its "disabled" state)
    $("#did-you-mean-on").removeAttr("disabled");
    $("#did-you-mean-off").removeAttr("disabled");

    if ($("#dymIndexExists").length == 0) {
        $("#did-you-mean-on").attr("disabled", "disabled");
        $("#did-you-mean-off").attr("disabled", "disabled");
        $("label.did-you-mean").css("color", "#ccc");
        $("#did-you-mean-warning").show(); 
    }

});
