
var shipping = 0;
$(document).ready(function () {
    $(".form-check-input").click(function (e) {
        shipping = 0;
        var total = parseFloat($("#initial_total").val());
        var TTC = parseFloat($("#init_ttc").val());

        if (e.target.value != "Local pickup") { shipping = 60; total += shipping; TTC += shipping; }
        $("#shipping_hid").val(shipping);
        $("#shipping_fee").text(shipping + " DH");
        $("#total").text(total + " DH");
        $("#ttc").text(TTC + " DH");

        $("#shipping_li, #total_li").show("slow");
    });
    if ($("#hide-shipping").text()) $("#shipping_div").hide();
});

function generate_quote(e) {
    var btn = $("#main_form").find("button[type=submit]:focus");
    if (btn.attr("name") == "btn_quote") {
        window.location.href = "/generate/quote?" + $('#main_form').serialize();
        return false;
    }
    else {
        return true;
    }
}

