<?php include "app_modal.php"; ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/js/bootstrap.min.js"></script>
<!-- <script src="<?=site_url; ?>/designer/js/wow.min.js"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.1.20/jquery.fancybox.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js"></script>
<script>
    document.addEventListener('DOMContentLoaded', () => { 
    const buttons = document.querySelectorAll('.owl-carousel button');  
    buttons.forEach((button, index) => { 
        button.setAttribute('title', `button`);
    }); 
});
function stickyHeader() {

    if ($('.menubar').length) {

        var strickyScrollPos = 100;

        if ($(window).scrollTop() > strickyScrollPos) {

            $('.menubar').addClass('stricky-fixed');

        } else if ($(this).scrollTop() <= strickyScrollPos) {

            $('.menubar').removeClass('stricky-fixed');

        }

    };

}



jQuery(window).on('scroll', function() {

    (function($) {

        stickyHeader();

    })(jQuery);

});





if ($(".navigation").length) {

    $(".navigation .navbar button").on("click", function() {

        $(".navigation .menu").slideToggle();

        $(this).toggleClass('open');

        return false;

    });

    $(".navigation .cs-submenu").children("a").append(function() {

        return '<button class="dropdown-expander" title="dropdown"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/></svg></button>';

    });



}



if (document.documentElement.clientWidth < 1023) {

    $(".navigation .menu .dropdown-expander").on("click", function() {

        $(this).parent().parent().children(".cs-dropdown").slideToggle();

        console.log($(this).parents("li"));

        console.log($(this).parents().children(".dropdown-expander").toggleClass("rotated"));

        return false

    })

    $(document).click(function(e) {

        if (!$(e.target).closest('.navigation .navbar button').length) {

            $('.navigation .menu').stop(true).slideUp();

            $(".navigation .navbar button").removeClass('open');



        }

    });

}



var offers = $("#offers");

offers.owlCarousel({

    loop: false,

    margin: 0,

    navSpeed: 500,

    nav: false,

    navText: [
        '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/></svg>',
        '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>'
    ],

    autoplay: true,

    dots: false,

    items: 1,

    responsiveClass: true,

    responsive: {

        0: {

            nav: false

        },

        600: {

            nav: false

        },

        1024: {},

        1100: {}

    }

});





var testimonials = $("#testimonials");

testimonials.owlCarousel({

    loop: true,

    margin: 15,

    navSpeed: 500,

    nav: false,

    navText: [
        '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/></svg>',
        '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>'
    ],

    autoplay: true,

    dots: false,

    items: 2,

    responsiveClass: true,

    responsive: {

        0: {

            items: 1

        },

        600: {

            items: 1,

        },

        1024: {

            items: 2

        },

        1100: {

            items: 2

        }

    }

});





var clients = $("#clients");

clients.owlCarousel({

    loop: true,

    margin: 15,

    navSpeed: 500,

    nav: false,

    navText: [
        '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/></svg>',
        '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>'
    ],

    autoplay: true,

    dots: true,

    items: 6,

    responsiveClass: true,

    responsive: {

        0: {

            items: 2

        },

        600: {

            items: 2,

        },

        1024: {

            items: 6

        },

        1100: {

            items: 6

        }

    }

});


$(window).on('scroll', function() {

    if ($(this).scrollTop() > 100) {

        $('#web-pulse-scroll-up').fadeIn();

    } else {

        $('#web-pulse-scroll-up').fadeOut();

    }

});

$('#web-pulse-scroll-up').on('click', function() {

    $("html, body").animate({

        scrollTop: 0

    }, 600);

    return false;

});



lozad('.lozad', {

    load: function(el) {

        el.src = el.dataset.src;

        el.onload = function() {

            el.classList.add('fadess')

        }

    }

}).observe();

$('#thumbs img').click(function() {

    $('#largeImage').attr('src', $(this).attr('src').replace('thumb', 'large'));

    if ($(this).hasClass("active")) {

        $("#thumbs img").removeClass("active");

    } else {

        $("#thumbs img").removeClass("active");

        $(this).addClass("active");

    }

});

var a = 0;
$(window).scroll(function() {
    var oTop = $(".spancount").offset().top - window.innerHeight;
    if (a == 0 && $(window).scrollTop() > oTop) {
        $(".counter").each(function() {
            var $this = $(this),
                countTo = $this.attr("data-number");
            $({
                countNum: $this.text()
            }).animate({
                    countNum: countTo
                },

                {
                    duration: 2000,
                    easing: "swing",
                    step: function() {
                        //$this.text(Math.ceil(this.countNum));
                        $this.text(
                            Math.ceil(this.countNum).toLocaleString("en")
                        );
                    },
                    complete: function() {
                        $this.text(
                            Math.ceil(this.countNum).toLocaleString("en")
                        );
                        //alert('finished');
                    }
                }
            );
        });
        a = 1;
    }
});

//disabling context menu
document.onkeydown = function(e) {
    if (e.ctrlKey &&
        (e.keyCode === 67 ||
            e.keyCode === 86 ||
            e.keyCode === 85 ||
            e.keyCode === 117)) {
        return false;
    } else {
        return true;
    }
};
$(document).keypress("u", function(e) {
    if (e.ctrlKey) {
        return false;
    } else {
        return true;
    }
});
document.addEventListener("contextmenu", function(e) {
    e.preventDefault();
}, false);
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.9.0/jquery.validate.min.js"></script>

<script>
$(document).ready(function() {
    $("#quick_enquiry").validate({
        rules: {
            name: "required",
            message: "required",
            location: "required",
            email: {
                required: true,
                email: true
            },
            mobile: {
                required: true,
                number: true,
                minlength: 10,
            }
        },
        messages: {
            name: "Please enter your name",
            message: "Please enter message",
            email: {
                required: "Please enter your email address"
            },
            location: "Please enter your location",
            mobile: {
                required: "Please enter your mobile no.",
                number: "Mobile No. contains only numbers",
                minlength: "Your Mobile No. must be at least 10 characters long",
            }
        },
    });
    $("#contact_form").validate({
        rules: {
            name: "required",
            message: "required",
            location: "required",
            email: {
                required: true,
                email: true
            },
            mobile: {
                required: true,
                number: true,
                minlength: 10,
            }
        },
        messages: {
            name: "Please enter your name",
            message: "Please enter message",
            email: {
                required: "Please enter your email address"
            },
            location: "Please enter your location",
            mobile: {
                required: "Please enter your mobile no.",
                number: "Mobile No. contains only numbers",
                minlength: "Your Mobile No. must be at least 10 characters long",
            }
        },
    });
})
$(document).ready(function() {
    $("#whatsapp_form").validate({
        rules: {
            name: "required",
            mobile: {
                required: true,
                number: true,
                minlength: 10,
                maxlength: 10,
            }
        },
        messages: {
            name: "Please Enter Your Name",
            mobile: {
                required: "Please Enter Your mobile Number",
                number: "Mobile Number Must be Number",
                minlength: "Mobile Number must have 10 digits",
                maxlength: "Mobile Number must have 10 difits",
            }
        },
    });
});
</script>
<script>
function validateOnlyTextField(element) {
    var str = element.value;
    if (str == ' ') {
        element.value = "";
    }
    if (!(/^[a-zA-Z\s]+$/.test(str))) {
        // console.log('String contain number characters');
        str = str.substr(0, str.length - 1);
        element.value = "";
    }
}
$(document).ready(function() {
    $('#contact_form').submit(function(e) {
        e.preventDefault();
        $.ajax({
            'url': '<?= site_url; ?>/ajax_save_contact.php',
            'type': 'POST',
            'dataType': 'json',
            'data': $(this).serialize(),
            'success': function(result) {
                if (result.status == false) {
                    $('.success_message').text('');
                    $('.error_message').text(result.message_response)
                } else {
                    $('.error_message').text('');
                    $('.success_message').text(result.message_response);
                    $('#contact_form').trigger("reset");
                }
                console.log(result.message_response);
            }
        })
    });
    $('#whatsapp_form').submit(function(e) {
        e.preventDefault();
        $.ajax({
            'url': '<?= site_url; ?>/ajax_save_whatsapp.php',
            'type': 'POST',
            'dataType': 'json',
            'data': $(this).serialize(),
            'success': function(result) {
                if (result.status == false) {
                    $('.wht_success_message').text('');
                    $('.wht_error_message').text(result.message_response)
                } else {
                    $('.wht_error_message').text('');
                    $('.wht_success_message').text(
                        "You Have Successfully Submitted enquiry. We will contact you soon."
                        );
                    $('#whatsapp_form').trigger("reset");
                    window.open(result.message_response, '_blank');
                }
            }
        });
    });
    $('#callback_form').submit(function(e) {
        e.preventDefault();
        $.ajax({
            'url': '<?= site_url; ?>/ajax_save_callback.php',
            'type': 'POST',
            'dataType': 'json',
            'data': $(this).serialize(),
            'success': function(result) {
                if (result.status == false) {
                    $('.call_success_message').text('');
                    $('.call_error_message').text(result.message_response)
                } else {
                    $('.call_error_message').text('');
                    $('.call_success_message').text(result.message_response);
                    $('#callback_form').trigger("reset");
                }
            }
        });
    });
    $('#product_pop_form1').submit(function(e) {
        e.preventDefault();
        $.ajax({
            'url': '<?= site_url; ?>/ajax_save_catenq.php',
            'type': 'POST',
            'dataType': 'json',
            'data': $(this).serialize(),
            'success': function(result) {
                if (result.status == false) {
                    $('.pro_success_message').text('');
                    $('.pro_error_message').text(result.message_response)
                } else {
                    $('.pro_error_message').text('');
                    $('.pro_success_message').text(result.message_response);
                    $('#product_pop_form1').trigger("reset");
                }
            }
        })
    });
    $('#quick_enquiry').submit(function(e) {
        e.preventDefault();
        $.ajax({
            'url': '<?= site_url; ?>/ajax_save_contact.php',
            'type': 'POST',
            'dataType': 'json',
            'data': $(this).serialize(),
            'success': function(result) {
                if (result.status == false) {
                    $('.cat_success_message').text('');
                    $('.cat_error_message').text(result.message_response)
                } else {
                    $('.cat_error_message').text('');
                    $('.cat_success_message').text(result.message_response);
                    $('#quick_enquiry').trigger("reset");
                }
            }
        })
    });
});
</script>
<script>
$(document).ready(function() {
    $('.main-category-image').click(function() {
        var cat_image = $('.main-cat-image').attr('src');
        var cat_title = $('.main-cat-image').attr('title');
        var cat_heading = $('.main_heading').val();
        $('.product_popup_image').find("img").attr("src", cat_image);
        $('.pop_heading').text(cat_heading);
        $('.product_popup_image').find("img").attr("alt", cat_title);
        $('.product_popup_image').find("img").attr("title", cat_title);
    });
    $('.pop_cat_id').click(function() {
        var cat_image = "";
        var cat_title = "";
        var image_title = "";
        var cat_id = $(this).find('.cat_id').val();
        cat_image = $('.category_image' + cat_id).attr('src');
        image_title = $('.category_image' + cat_id).attr('title');
        cat_title = $('.category_title' + cat_id).text();
        $('.pop_heading').text(cat_title);
        $('.product_popup_image').find("img").attr("src", cat_image);
        $('.product_popup_image').find("img").attr("alt", image_title);
        $('.product_popup_image').find("img").attr("title", image_title);

    });
    $('.product_pop_up').click(function() {
        var product_id = $(this).find('.product_id').val();
        var imagepr = $('.product_image' + product_id).attr('src');
        var image_title = $('.product_image' + product_id).attr('title');
        var product_title = $('.product_title' + product_id).text();
        $('.product_popup_image').find("img").attr("src", imagepr);
        $('.pop_heading').text(product_title);
        $('.product_popup_image').find("img").attr("alt", image_title);
        $('.product_popup_image').find("img").attr("title", image_title);
    });
    $('.Request_call_back').click(function() {
        var product_id = $(this).find('.product_id').val();
        var imagepr = $('.product_image' + product_id).attr('src');
        var image_title = $('.product_image' + product_id).attr('title');
        var product_title = $('.product_title' + product_id).text();
        $('.product_cat_image').find("img").attr("src", imagepr);
        $('.catHeading').text(product_title);
        $('.product_cat_image').find("img").attr("alt", image_title);
        $('.product_cat_image').find("img").attr("title", image_title);
    });
});
</script>


<script>
$(document).ready(function() {
    $("#product_pop_form1").validate({
        rules: {
            name: "required",
            message: "required",
            location: "required",
            quantity: {
                    required: true,
                },
            email: {
                required: true,
                email: true
            },
            mobile: {
                required: true,
                number: true,
                minlength: 10,
            }
        },
        messages: {
            name: "Please enter your name",
            message: "Please enter message",
            email: {
                required: "Please enter your email address"
            },
            location: "Please enter your location",
            quantity: {
                    required: "Please enter Your Minimum Order Quantity",
                },
            mobile: {
                required: "Please enter your mobile no.",
                number: "Mobile No. contains only numbers",
                minlength: "Your Mobile No. must be at least 10 characters long",
            }
        },
    });
    $("#callback_form").validate({
        rules: {
            name: "required",
            mobile: {
                required: true,
                number: true,
                minlength: 10,
                maxlength: 10,
            }
        },
        messages: {
            name: "Please Enter Your Name",
            mobile: {
                required: "Please Enter Your mobile Number",
                number: "Mobile Number Must be Number",
                minlength: "Mobile Number must have 10 digits",
                maxlength: "Mobile Number must have 10 difits",
            }
        },
    });
    $('.product_aimage').click(function() {
        var pr_image = $(this).attr('src');
        var s_no = $(this).siblings('.pr_sno').val();
        $('.activeImage' + s_no).attr('src', pr_image);
    });
})
</script>