(function ($) {
    $(document).on('ready', function () {
        if(window.yaCounter38082510 !== undefined){

            $('#phone span.phone').on('click', function(){
                yaCounter38082510.reachGoal('call_back_header_span_phone');
                console.log('call_back_header_span_phone');
            });
            $('#back_call_form').on('submit', function () {
                yaCounter38082510.reachGoal('submit_call_back_header');
                console.log('submit_call_back_header');
            });
            $('#product a.add_quick_order').on('click', function () {
                yaCounter38082510.reachGoal('product_quick_order');
                console.log('product_quick_order');
            });
            $('#quick_orders_form').on('submit', function () {
                yaCounter38082510.reachGoal('submit_product_quick_order');
                console.log('submit_product_quick_order');
            });
            $('*[data-open="cart_widget"]').on('click', function () {
                yaCounter38082510.reachGoal('popup_cart_widget');
                console.log('popup_cart_widget');
            });
            $(document).on('click','#quick_cart_order', function () {
                yaCounter38082510.reachGoal('popup_cart_widget_quick_order_form');
                console.log('popup_cart_widget_quick_order_form');
            });
            $('#simple_form_popup').one('submit.send', function (e) {
                if(e.namespace != 'send') return false;
                yaCounter38082510.reachGoal('popup_cart_widget_quick_order_form_submit');
                console.log('popup_cart_widget_quick_order_form_submit');
            });
            $(document).on('click','#cart_popup a[href="/cart"]', function () {
                yaCounter38082510.reachGoal('popup_cart_widget_go_to_cart');
                console.log('popup_cart_widget_go_to_cart');
            });
            $('a[href="#simple_checkout"]').on('click', function () {
                yaCounter38082510.reachGoal('tab_simple_checkout');
                console.log('tab_simple_checkout');
            });
            $('#simple_checkout #simple_form').on('submit.send', function (e) {
                if(e.namespace != 'send') return false;
                yaCounter38082510.reachGoal('simple_checkout_form_send');
                console.log('simple_checkout_form_send');
            });



            $('#phone button.my_btn').on('click', function(){
                yaCounter38082510.reachGoal('call_back_header');
                console.log('call_back_header');
            });

            $('#lg-wg-call-circle').on('click', function(){
                yaCounter38082510.reachGoal('call_back_footer');
                console.log('call_back_footer');
            });

            if(window.location.pathname == '/') {
                $(document).on('click', '#quick_orders_form .form-group button', function () {
                    yaCounter38082510.reachGoal('quick_order_call');
                    console.log('quick_order_call');
                });

                $(document).on('click', '#quick_orders_form .form-group a', function () {
                    yaCounter38082510.reachGoal('quick_orders_go_product');
                    console.log('quick_orders_go_product');
                });
            }

            if(window.ga !== undefined){

                $('#phone span.phone').on('click', function(){
                    ga('send', {
                        hitType: 'event',
                        eventCategory: 'click',
                        eventAction: 'call_back_header_span_phone',
                    });
                    console.log('GA','call_back_header_span_phone');
                });
                $('#back_call_form').on('submit', function () {
                    ga('send', {
                        hitType: 'event',
                        eventCategory: 'submit',
                        eventAction: 'submit_call_back_header',
                    });
                    console.log('GA','submit_call_back_header');
                });
                $('#product a.add_quick_order').on('click', function () {
                    ga('send', {
                        hitType: 'event',
                        eventCategory: 'click',
                        eventAction: 'product_quick_order',
                    });
                    console.log('GA','product_quick_order');
                });
                $('#quick_orders_form').on('submit', function () {
                    ga('send', {
                        hitType: 'event',
                        eventCategory: 'submit',
                        eventAction: 'submit_product_quick_order',
                    });
                    console.log('GA','submit_product_quick_order');
                });
                $('*[data-open="cart_widget"]').on('click', function () {
                    ga('send', {
                        hitType: 'event',
                        eventCategory: 'click',
                        eventAction: 'popup_cart_widget',
                    });
                    console.log('GA','popup_cart_widget');
                });
                $(document).on('click','#quick_cart_order', function () {
                    ga('send', {
                        hitType: 'event',
                        eventCategory: 'click',
                        eventAction: 'popup_cart_widget_quick_order_form',
                    });
                    console.log('GA','popup_cart_widget_quick_order_form');
                });
                $('#simple_form_popup').one('submit.send', function (e) {
                    if(e.namespace != 'send') return false;
                    ga('send', {
                        hitType: 'event',
                        eventCategory: 'submit',
                        eventAction: 'popup_cart_widget_quick_order_form_submit',
                    });
                    console.log('GA','popup_cart_widget_quick_order_form_submit');
                });
                $(document).on('click','#cart_popup a[href="/cart"]', function () {
                    ga('send', {
                        hitType: 'event',
                        eventCategory: 'click',
                        eventAction: 'popup_cart_widget_go_to_cart',
                    });
                    console.log('GA','popup_cart_widget_go_to_cart');
                });
                $('a[href="#simple_checkout"]').on('click', function () {
                    ga('send', {
                        hitType: 'event',
                        eventCategory: 'click',
                        eventAction: 'tab_simple_checkout',
                    });
                    console.log('GA','tab_simple_checkout');
                });
                $('#simple_checkout #simple_form').on('submit.send', function (e) {
                    if(e.namespace != 'send') return false;
                    ga('send', {
                        hitType: 'event',
                        eventCategory: 'submit',
                        eventAction: 'simple_checkout_form_send',
                    });
                    console.log('GA','simple_checkout_form_send');
                });
            }

        }
    });
})(jQuery);