jQuery(document).ready(function ($) {
    var $itemform = $('#wpgv-giftitems'),
        $cataccording = $('.wpgv-according-category'),
        $itemswrap = $('.wpgv-items-wrap'),
        $step1 = $('#wpgv-giftitems-step1'),
        $step2 = $('#wpgv-giftitems-step2'),
        $step3 = $('#wpgv-giftitems-step3'),
        $step4 = $('#wpgv-giftitems-step4'),
        $wpgv_category_id = $('#category_id'),
        $wpgv_item_id = $('#item_id'),
        $chooseStyle = $('#chooseStyle'),
        $wpgv_total_price = $('#total_price'),
        $website_commission_price = $('#website_commission_price'),
        $buying_for = $('#buying_for'),
        $your_name = $('#your_name'),
        $recipient_name = $('#recipient_name'),
        $list_view_price = $('#list_view_price'),
        $message = $('#message'),
        $shipping = $('#shipping'),
        $shipping_email = $('#shipping_email'),
        $receipt_email = $('#receipt_email'),
        $company_name = $('#company_name'),
        $address_line1 = $('#address_line1'),
        $address_line2 = $('#address_line2'),
        $address_line3 = $('#address_line3'),
        $address_line4 = $('#address_line4'),
        $post_firstname = $('#post_firstname'),
        $post_lastname = $('#post_lastname'),
        $post_address = $('#post_address'),
        $post_code = $('#post_code'),
        $shipping_method = $('#shipping_method'),
        $payemnt_gateway = $('#payemnt_gateway'),
        $autoyourname = $('#autoyourname'),
        $shippingbox = $('.order_details_preview .wpgv_shipping_box'),
        $totalbox = $('.order_details_preview .wpgv_total_box'),
        $itempricespan = $("#itemprice span"),
        $shippingpricespan = $("#shippingprice span"),
        $paynowbtnspan = $("#paynowbtn span"),
        $wpgv_date_time = $("#wpgv-giftitems #wpgv-date-time"),
        $voucherSendType = $("#wpgv-giftitems #voucherSendType"),
        $totalpricespan = $("#totalprice span");
    if ($('#coupon_code_length').length) {
        var numberlenght = $('#coupon_code_length').val()
        var stringlenght = '1';
        var stringlenght1 = '9';
        for (var i = 0; i < numberlenght - 1; i++) {
            stringlenght += 0
            stringlenght1 += 0
        }
        stringlenght = parseFloat(stringlenght);
        stringlenght1 = parseFloat(stringlenght1);
        $('.codeCard').val(Math.floor(stringlenght + Math.random() * stringlenght1));
    }

    $("#wpgv-giftitems #voucherSendType").change(function () {
        var selected_option = $('#wpgv-giftitems #voucherSendType').val();

        if (selected_option == "send_instantly") {
            $("#wpgv-giftitems .voucherSendDatePikerRow").hide();
        } else {
            $("#wpgv-giftitems .voucherSendDatePikerRow").show().css({
                "height": "auto"
            });
        }
    });

    var date = new Date();
    date.setDate(date.getDate());

    $('#wpgv-giftitems .voucherSendDatePiker').datetimepicker({
        startDate: date,
        minDate: date,
        dateFormat: 'yy-mm-dd'
    });

    $('.wpgv-according-category:not(:first-child)').addClass('catclose');
    $('.wpgv-giftitem-wrapper .wpgv_preview-box:not(:nth-child(2))').addClass('mailhidden');
    $('.wpgv-according-category:not(:first-child) .wpgv-items').slideUp();
    $('.wpgv-according-title').click(function () {
        var $catid = $(this).data('cat-id');
        $.ajax({
            url: frontend_ajax_object.ajaxurl,
            type: "POST",
            data: "action=wpgv_doajax_get_itemcat_image&catid=" + $catid,
            success: function (data) {
                $(".wpgv-giftitemimage img").attr('src', data.image);
            }
        });
        $cataccording.addClass('catclose');
        $cataccording.find('.wpgv-items').slideUp();
        $('#itemcat' + $catid).removeClass('catclose');
        $('#itemcat' + $catid).find('.wpgv-items').slideDown();
    });
    $('.wpgv-buy button').click(function () {
        var $itemid = $(this).data('item-id')
        $catid = $(this).data('cat-id'),
            $itemprice = $(this).data('item-price');
        $item_price_pdf = $(this).data('item-price-pdf');

        $("#item_pdf_price").val($item_price_pdf);
        $wpgv_item_id.val($itemid);
        if ($itemprice) {
            $list_view_price.val($itemprice);
            $list_view_price.attr("disabled", "disabled");
            $list_view_price.attr("style", "cursor: no-drop;");
        } else {
            $list_view_price.val('');
            $list_view_price.attr("disabled", false);
            $list_view_price.attr("style", "");
        }
        $wpgv_category_id.val($catid);
        $step1.fadeOut();
        $step2.fadeIn();
        $.ajax({
            url: frontend_ajax_object.ajaxurl,
            type: "POST",
            data: "action=wpgv_doajax_get_item_data&itemid=" + $itemid,
            success: function (data) {
                $(".wpgv-gifttitle h3, .itemtitle").html(data.title);
                $(".wpgv-gifttitle span, .itemdescription").html(data.description);
                var $price = (data.special_price) ? data.special_price : data.price;
                $('.voucherValueCard').val($price);
                $.each(data.images, function (key, value) {
                    $(".wpgvstyle" + (parseInt(key) + 1) + " .cardDiv .cardImgTop img").attr('src', value);
                });
            }
        });
    });
    $('.next-button').click(function (e) {
        var $nextwrap = $(this).data('next'),
            $result = wpgv_validateitemform($nextwrap);
        if (!$result) return;
        $itemform.addClass('loading');
        $itemswrap.fadeOut();
        setTimeout(function () {
            $itemform.removeClass('loading');
            $('#wpgv-giftitems-' + $nextwrap).fadeIn();
        }, 500);
    });
    $('.back-button').click(function (e) {
        var $prevwrap = $(this).data('prev');
        $itemform.addClass('loading');
        $itemswrap.fadeOut();
        setTimeout(function () {
            $itemform.removeClass('loading');
            $('#wpgv-giftitems-' + $prevwrap).fadeIn();
        }, 500);
    });

    $your_name.on('input blur', function () {
        var dInput = this.value;
        $(".forNameCard").val(dInput);
    });
    $recipient_name.on('input blur', function () {
        var dInput = this.value;
        $(".fromNameCard").val(dInput);
    });
    $list_view_price.on('input blur', function () {
        var dInput = this.value;
        $(".voucherValueCard").val(dInput);
    });
    $message.on('input blur', function () {
        var dInput = this.value;
        $(".personalMessageCard").val(dInput);
    });
    $('.buying-options div').click(function (e) {
        $('.buying-options div').removeClass('selected');
        $(this).addClass('selected');
        $buying_for.val($(this).data('value'));
        if ($(this).data('value') == 'yourself') {
            $recipient_name.closest('.wpgv-form-fields').fadeOut();
            $('.nameFormRight').css('opacity', 0);
            $shipping_email.closest('.wpgv-form-fields').addClass('mailhidden');

            $voucherSendType.val("send_instantly").change();
            $voucherSendType.closest(".voucherSelectSend").hide();
            $wpgv_date_time.closest(".voucherSendDatePikerRow").hide();
        } else {
            $voucherSendType.val("send_instantly").change();
            $voucherSendType.closest(".voucherSelectSend").show();

            $recipient_name.closest('.wpgv-form-fields').fadeIn();
            $('.nameFormRight').css('opacity', 1);
            $shipping_email.closest('.wpgv-form-fields').removeClass('mailhidden');
        }
    });
    if ($buying_for.val() == 'yourself') {
        $recipient_name.closest('.wpgv-form-fields').fadeOut();
        $('.nameFormRight').css('opacity', 0);
        $shipping_email.closest('.wpgv-form-fields').addClass('mailhidden');
    } else {
        $recipient_name.closest('.wpgv-form-fields').fadeIn();
        $('.nameFormRight').css('opacity', 1);
        $shipping_email.closest('.wpgv-form-fields').removeClass('mailhidden');
    }
    $('.shipping-options div').click(function (e) {
        $('.shipping-options div').removeClass('selected');
        $(this).addClass('selected');
        $shipping.val($(this).data('value'));
        var $shipping_method_wrapper = $shipping_method.closest('.wpgv-form-fields');
        var $totalprice = 0;

        var voucherSendType = jQuery('#wpgv-giftitems #voucherSendType');
        var voucherdate = jQuery('#wpgv-giftitems #wpgv-date-time');

        if ($(this).data('value') == 'shipping_as_post') {
            $shipping_email.closest('.wpgv-form-fields').hide();
            $post_firstname.closest('.wpgv-form-fields').show();
            $receipt_email.closest('.wpgv-form-fields').show();
            $shipping_email.closest('.wpgv-form-fields').find('.error').hide();
            $receipt_email.closest('.wpgv-form-fields').find('.error').hide();
            $receipt_email.closest('.wpgv-form-fields').find('.eqlerror').hide();
            $shippingbox.css('display', 'flex');
            $totalbox.css('display', 'flex');
            $shipping_method_wrapper.show();
            $shippingpricespan.html($shipping_method_wrapper.find(':nth-child(2)').data('value'));
            $shipping_method_wrapper.find(':nth-child(2) input').prop("checked", true);

            $totalprice = (parseFloat($itempricespan.html()) + parseFloat($shippingpricespan.html()) + parseFloat($website_commission_price.data('price'))).toFixed(2);
            $totalpricespan.html($totalprice);
            $paynowbtnspan.html($totalprice);
            $wpgv_total_price.val($totalprice);

            $voucherSendType.val("send_instantly").change();
            $voucherSendType.closest(".voucherSelectSend").hide();
            $wpgv_date_time.closest(".voucherSendDatePikerRow").hide();
        } else {
            var activeOption = jQuery('#wpgv-giftitems-step2 .buying-options div.selected');
            if (activeOption.length) {
                var dataValue = activeOption.data('value');

                if (dataValue === 'someone_else') {
                    $voucherSendType.val("send_instantly").change();
                    $voucherSendType.closest(".voucherSelectSend").show();
                } else {
                    $voucherSendType.val("send_instantly").change();
                    $voucherSendType.closest(".voucherSelectSend").hide();
                    $wpgv_date_time.closest(".voucherSendDatePikerRow").hide();
                }
            }


            $shipping_email.closest('.wpgv-form-fields').show();
            $receipt_email.closest('.wpgv-form-fields').show();
            $post_firstname.closest('.wpgv-form-fields').hide();
            $shipping_email.closest('.wpgv-form-fields').find('.error').hide();
            $receipt_email.closest('.wpgv-form-fields').find('.error').hide();
            $receipt_email.closest('.wpgv-form-fields').find('.eqlerror').hide();
            $shipping_method_wrapper.hide();
            $totalprice = (parseFloat($itempricespan.html()) + parseFloat($website_commission_price.data('price')));
            $shippingbox.hide();

            $totalpricespan.html($totalprice);
            $paynowbtnspan.html($totalprice);
            $wpgv_total_price.val($totalprice);
        }
    });

    $('input[name="shipping_method"]').change(function () {
        var $shippingprice = $(this).closest('label').data('value');
        var $totalprice = (parseFloat($itempricespan.html()) + parseFloat($shippingprice) + parseFloat($website_commission_price.data('price'))).toFixed(2);
        $shippingpricespan.html($shippingprice);
        $totalpricespan.html($totalprice);
        $paynowbtnspan.html($totalprice);
        $wpgv_total_price.val($totalprice);
        // $('.voucherValueCard').val($totalprice);
    });

    $chooseStyle.on('change', function () {
        $('.wpgv_preview-box').addClass('mailhidden');
        $itemform.addClass('loading');
        setTimeout(function () {
            $itemform.removeClass('loading');
        }, 1000);
        $('.wpgvstyle' + (parseInt($(this).val()) + 1)).removeClass('mailhidden');
    });

    $('#itempreview').click(function () {
        var $url = $(this).data('url'),
            $urlstring = wpgv_formdata();
        window.open($url + $urlstring, '_blank');
    });

    $('#paynowbtn').click(function () {
        var $error = 0,
            $datastring = '',
            $url = $(this).data('url'),
            $urlstring = wpgv_formdata();

        var isRecaptchaEnabled = frontend_ajax_object.isRecaptchaEnabled;
        var recaptcha_site_key = frontend_ajax_object.recaptcha_site_key;
        var recaptcha_secret_key = frontend_ajax_object.recaptcha_secret_key;
        var recaptchaResponse = '';

        if (isRecaptchaEnabled == 1 && recaptcha_site_key && recaptcha_secret_key) {
            recaptchaResponse = grecaptcha.getResponse();
        }


        if ($('#voucherSendType').val() == "send_instantly") {
            var send_email_date_time = wpgv_b64EncodeUnicode("send_instantly");
        } else {
            var send_email_date_time = wpgv_b64EncodeUnicode($('#voucherSendDate').val());
        }
        if ($shipping.val() == 'shipping_as_email') {
            if ($buying_for.val() == 'someone_else' && !($shipping_email.val() && wpgv_validateEmail($shipping_email.val()))) {
                $error = 1;
                $shipping_email.closest('.wpgv-form-fields').find('.error').show();
            } else {
                $shipping_email.closest('.wpgv-form-fields').find('.error').hide();
            }

            if (!($receipt_email.val() && wpgv_validateEmail($receipt_email.val()))) {
                $error = 1;
                $receipt_email.closest('.wpgv-form-fields').find('.error').show();
            } else {
                $receipt_email.closest('.wpgv-form-fields').find('.error').hide();
            }

            if ($voucherSendType.val() == "send_future_date") {
                if ($wpgv_date_time.val()) {
                    $wpgv_date_time.closest('.voucherSendDatePiker ').find('.error').hide();
                } else {
                    $error = 1;
                    $wpgv_date_time.closest('.voucherSendDatePiker ').find('.error').show();
                }
            }
            $datastring = $url + $urlstring + '&shipping=' + wpgv_b64EncodeUnicode($shipping.val()) + '&shipping_email=' + wpgv_b64EncodeUnicode($shipping_email.val()) + '&receipt_email=' + wpgv_b64EncodeUnicode($receipt_email.val()) + '&paymentmethod=' + wpgv_b64EncodeUnicode($payemnt_gateway.val()) + '&seller_company_name=' + wpgv_b64EncodeUnicode($company_name.val()) + '&seller_addr_line1=' + wpgv_b64EncodeUnicode($address_line1.val()) + '&seller_addr_line2=' + wpgv_b64EncodeUnicode($address_line2.val()) + '&seller_addr_line3=' + wpgv_b64EncodeUnicode($address_line3.val()) + '&seller_addr_line4=' + wpgv_b64EncodeUnicode($address_line4.val()) + '&send_email_date_time=' + send_email_date_time;

        } else if ($shipping.val() == 'shipping_as_post') {

            if (!($receipt_email.val() && wpgv_validateEmail($receipt_email.val()))) {
                $error = 1;
                $receipt_email.closest('.wpgv-form-fields').find('.error').show();
            } else {
                $receipt_email.closest('.wpgv-form-fields').find('.error').hide();
                $company_name.closest('.wpgv-form-fields').find('.error').hide();
                $receipt_email.closest('.wpgv-form-fields').find('.eqlerror').hide();
            }
            $datastring = $url + $urlstring + '&shipping=' + wpgv_b64EncodeUnicode($shipping.val()) + '&receipt_email=' + wpgv_b64EncodeUnicode($receipt_email.val()) + '&firstname=' + wpgv_b64EncodeUnicode($post_firstname.val()) + '&lastname=' + wpgv_b64EncodeUnicode($post_lastname.val()) + '&address=' + wpgv_b64EncodeUnicode($post_address.val()) + '&pincode=' + wpgv_b64EncodeUnicode($post_code.val()) + '&shipping_method=' + wpgv_b64EncodeUnicode($('input[name=shipping_method]:checked').val()) + '&paymentmethod=' + wpgv_b64EncodeUnicode($payemnt_gateway.val()) + '&seller_company_name=' + wpgv_b64EncodeUnicode($company_name.val()) + '&seller_addr_line1=' + wpgv_b64EncodeUnicode($address_line1.val()) + '&seller_addr_line2=' + wpgv_b64EncodeUnicode($address_line2.val()) + '&seller_addr_line3=' + wpgv_b64EncodeUnicode($address_line3.val()) + '&seller_addr_line4=' + wpgv_b64EncodeUnicode($address_line4.val()) + '&send_email_date_time=' + send_email_date_time;

        }


        if (!$('input[name=acceptVoucherTerms]').is(':checked')) {
            alert(frontend_ajax_object.accept_terms);
            return false;
        }

        if (isRecaptchaEnabled == 1) {
            if (recaptchaResponse.length === 0) {
                alert(frontend_ajax_object.accept_recaptcha);
                return false;
            } else {
                $datastring += '&recaptcha_response=' + recaptchaResponse;
            }
        }
        var verifyValue = $('input[name="wpgv_giftitems_form_verify"]').val();
        if (verifyValue && verifyValue.trim() !== '') {
            $datastring += '&nonce=' + encodeURIComponent(verifyValue);
        }

        if (!$error) {
            $(this).attr("style", "pointer-events: none");
            $.ajax({
                url: frontend_ajax_object.ajaxurl,
                type: "POST",
                data: $datastring,
                success: function (response) {

                    if (response.success) {
                        if (response.data.approve_link) {
                            window.location = response.data.approve_link;
                        } else if (response.data.client_token && response.data.session_id) {
                            if (window.wpgvKlarna && typeof window.wpgvKlarna.handleResponse === 'function') {
                                window.wpgvKlarna.handleResponse(response);
                                jQuery('.wpgv-checkout-form').hide();
                                jQuery('#klarna-payments-container').show();
                            } else {
                                alert('Klarna checkout is not available. Please refresh the page and try again.');
                            }
                        } else {
                            alert("No redirect link found.");
                        }
                    } else {
                        alert(response.data.message);
                    }

                },
                error: function () {
                    alert(frontend_ajax_object.error_occur);
                }
            });
        } else {

            alert(frontend_ajax_object.required);
        }
    });

    $(document).ajaxStart(function () { $itemform.addClass('loading'); })
        .ajaxStop(function () { $itemform.removeClass('loading'); });

    function wpgv_validateitemform($step) {
        $status = 0;
        if ($step == 'step3') {
            if ($buying_for.val() == 'yourself') {
                if ($your_name.val()) {
                    $status = 1;
                    $your_name.closest('.wpgv-form-fields').find('.error').hide();
                    $post_firstname.val($your_name.val());
                    $autoyourname.html($your_name.val());
                } else {
                    $status = 0;
                    $your_name.closest('.wpgv-form-fields').find('.error').show();
                }
            } else {
                if ($your_name.val()) {
                    $status = 1;
                    $your_name.closest('.wpgv-form-fields').find('.error').hide();
                    $post_firstname.val($your_name.val());
                    $autoyourname.html($your_name.val());
                } else {
                    $status = 0;
                    $your_name.closest('.wpgv-form-fields').find('.error').show();
                }
                if ($recipient_name.val()) {
                    $recipient_name.closest('.wpgv-form-fields').find('.error').hide();
                } else {
                    $status = 0;
                    $recipient_name.closest('.wpgv-form-fields').find('.error').show();
                }
            }
            if ($message.val().length > 250) {
                $status = 0;
                $message.closest('.wpgv-form-fields').find('.error').show();
            } else {
                $message.closest('.wpgv-form-fields').find('.error').hide();
            }

            var listPrice = parseInt($list_view_price.val());

            if (isNaN(listPrice) || listPrice <= 0) {
                $status = 0;
                $list_view_price.closest('.wpgv-form-fields').find('.error').show();
            } else {
                $status = 1;
                $list_view_price.closest('.wpgv-form-fields').find('.error').hide();
            }

            if ($status) {
                var $itemid = $wpgv_item_id.val();
                $.ajax({
                    url: frontend_ajax_object.ajaxurl,
                    type: "POST",
                    data: "action=wpgv_doajax_get_item_data&itemid=" + $itemid,
                    success: function (data) {
                        var $valueInputPrice = $list_view_price.val();
                        $(".wpgv-itemtitle").html(data.title);
                        var $price = (data.special_price) ? data.special_price : data.price;
                        if ($price !== "") {
                            $itempricespan.html((parseFloat($price).toFixed(2)));
                            var $totalprice = (parseFloat($price) + parseFloat($website_commission_price.data('price'))).toFixed(2);
                        } else {
                            $itempricespan.html((parseFloat($valueInputPrice).toFixed(2)));
                            var $totalprice = (parseFloat($valueInputPrice) + parseFloat($website_commission_price.data('price'))).toFixed(2);
                            $("#item_pdf_price").val($totalprice);
                        }
                        $totalpricespan.html($totalprice);
                        $paynowbtnspan.html($totalprice);
                        $wpgv_total_price.val(parseFloat(data.price).toFixed(2));
                    }
                });
            }
        }
        return $status;
    }

    function wpgv_formdata() {
        var $catid = wpgv_b64EncodeUnicode($wpgv_category_id.val()),
            $itemid = wpgv_b64EncodeUnicode($wpgv_item_id.val()),
            $style = wpgv_b64EncodeUnicode($chooseStyle.val()),
            $totalprice = wpgv_b64EncodeUnicode(parseFloat($("#item_pdf_price").val())),
            $buyingfor = wpgv_b64EncodeUnicode($buying_for.val()),
            $yourname = wpgv_b64EncodeUnicode($your_name.val()),
            $recipientname = wpgv_b64EncodeUnicode($recipient_name.val()),
            $recipientmessage = wpgv_b64EncodeUnicode($message.val());
        $codecard = $('.codeFormRight .codeCard').val();

        return '&catid=' + $catid + '&itemid=' + $itemid + '&style=' + $style + '&totalprice=' + $totalprice + '&buyingfor=' + $buyingfor + '&yourname=' + $yourname + '&recipientname=' + $recipientname + '&recipientmessage=' + $recipientmessage + '&couponcode=' + $codecard;
    }

    function wpgv_b64EncodeUnicode(str) {
        return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
            return String.fromCharCode(parseInt(p1, 16))
        }))
    }

    function wpgv_b64DecodeUnicode(str) {
        return decodeURIComponent(Array.prototype.map.call(atob(str), function (c) {
            return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
        }).join(''))
    }

    function wpgv_validateEmail($email) {
        var reg = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;

        if (reg.test($email) == false) {
            return false;
        }
        return true;
    }

    $('#wpgv-message #message').on('keydown', function (e) {
        newLines = $(this).val().split("\n").length;
        $('.maxchar').html(frontend_ajax_object.total_character + ": " + (this.value.length));
        if ((e.keyCode == 13 && newLines >= 3) || (e.keyCode != 8 && this.value.length > 250)) {
            return false;
        }
    });

    // Click handler for voucher quote suggestions (fills the nearest message textarea, updates mirror and char count)
    $(document).on('click', '.voucher-quotes li', function (e) {
        e.preventDefault();
        var text = $(this).text().trim();
        if (!text) return;

        // Find the nearest textarea in the same form/container as the clicked suggestion
        var $container = $(this).closest('form, .voucher-template-input, .wpgv-form-fields, #voucher-multistep-form, #wpgv-giftitems');
        var $desc = $container.find('textarea#voucherMessage, textarea#message, textarea#voucher_description, textarea[name="voucherMessage"], textarea[name="message"], textarea[name="voucher_description"]').first();
        if ($desc.length === 0) {
            // fallback to global ids used on other pages
            $desc = $('#voucherMessage, #message, #voucher_description');
        }

        // Insert the quote into the Personal Message textarea and trigger input events
        if ($desc.length) {
            $desc.val(text).trigger('input').trigger('change').trigger('keyup');
        }

        // Also update the preview/read-only mirror (if present)
        var $mirror = $container.find('.personalMessageCard');
        if ($mirror.length) {
            if ($mirror.is('textarea, input')) {
                $mirror.val(text);
            } else {
                $mirror.html(text);
            }
        }

        // Update character counter if present within the same container
        var $maxchar = $container.find('.maxchar').first();
        if ($maxchar.length && $desc.length) {
            $maxchar.html(frontend_ajax_object.total_character + ": " + text.length);
        }

        // Toggle active class on suggestion items within the same voucher-quotes block
        var $block = $(this).closest('.voucher-quotes');
        $block.find('ul li').removeClass('active');
        $(this).addClass('active');
    });

    // Show more quotes (reveal hidden list items)
    $(document).on('click', '.voucher-quotes .show-more-quotes', function (e) {
        e.preventDefault();
        var $parent = $(this).closest('.voucher-quotes');
        if (!$parent.length) return;
        $parent.find('ul li').show();
        $(this).hide();
    });
});