document.write("<script id='ze-snippet' src='https://static.zdassets.com/ekr/snippet.js?key=fff4b20d-4fd7-4369-8b0c-c0d4c46752ce'> </script>");

$( document ).ready(function() {


    var waitForZopim = setInterval(function () {
      
        if (window.$zopim === undefined || window.$zopim.livechat === undefined) {
            return;
        }
                    
        function setButtonURL() {
        	zE.activate();
        }
        
        
        $('.chat, .sproject').click( function(){
        	zE.activate();
        });
        $('.chat_now').click( function(){
        	zE.activate();
        });
        
        
        $('.thankyou-chat').click( function(){
        	zE.activate();
        });

    clearInterval(waitForZopim);

    }, 100);
	
	
	zE(function() {
        $zopim(function() {
           $zopim.livechat.setOnUnreadMsgs(unread);
            function unread(number) {
            if (number>=1)
            {
				$zopim.livechat.window.show();
            }
            }
        });
    });
    
   
            $('input[name=em]').on('change',function(){
                let customer_email = $(this).val();
                $zopim(function() {
                 $zopim.livechat.setEmail(customer_email);
                });
            });
            $('input[name=pn]').on('change',function(){
                let customer_number = $(this).val();
                $zopim(function() {
                  $zopim.livechat.setPhone(customer_number);
                });
            });
          
             $('input[name=cn]').on('change',function(){
                let customer_name = $(this).val();
                $zopim(function() {
                 $zopim.livechat.setName(customer_name);
                });
            });

            var currentURL = window.location.href;
            var currentIP = $("meta[name=ip2loc]").attr('content');

            $.ajax({
                type: "POST",
                url: "/order/visitor_log.php",
                data: {page_url : currentURL, client_ip: currentIP},
                dataType: "json",
                success: function(response){
                    console.log(response);
                }
            });

            

});