<?php include "app_modal_new.php"; ?>

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/wow/1.0.2/wow.min.js"></script>
<script src="https://unpkg.com/default-passive-events"></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="<?=site_url;?>/designer/js/lozad.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.9.0/jquery.validate.min.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.13/js/intlTelInput-jquery.min.js"></script> -->
<script src="<?=site_url;?>/designer/js/rbtools.min.js"></script>
<script src="<?=site_url;?>/designer/js/rs6.min.js"></script>
<script src="<?=site_url;?>/designer/js/themes_new.js"></script>
<script>
    $(function() {
        $("#contact_form").validate({
            rules: {
                name: "required",
                message: {
                    required: true,

                },
                location: {
                    required: true,

                },
                email: {
                    required: true,

                },
                mobile: {
                    required: true,
                    number: true,
                    minlength: 10,
                    maxlength: 10,
                }
            },
            messages: {
                name: "Please enter your name",
                message: {
                    required: "Please enter your message",

                },

                email: {
                    required: "Please enter your email address"
                },
                location: {
                    required: "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 digits long",
                    maxlength: "Your Mobile No. must be at least 10 digits long",
                }
            },
            submitHandler: function(form) {
                $.ajax({
                    url: '<?= site_url; ?>/contacts.php',
                    type: 'POST',
                    data: $('#contact_form').serialize(),
                    dataType: 'json',
                    success: function(response) {
                        if (response.status == true) {
                            $('#pop_up').text(response.message_response).css('color',
                                'green');
                            $('#contact_form')[0].reset();
                            grecaptcha.reset();

                        } else {
                            $('#pop_up').text(response.message_response).css('color',
                                'red');

                        }
                    }
                });

            }
        });



        $("#enq_pop_form").validate({
            rules: {
                name: "required",
                message: {
                    required: true,

                },
                location: {
                    required: true,

                },
                email: {
                    required: true,

                },
                mobile: {
                    required: true,
                    number: true,
                    minlength: 10,
                    maxlength: 10,
                }
            },
            messages: {
                name: "Please enter your name",
                message: {
                    required: "Please enter your message",

                },

                email: {
                    required: "Please enter your email address"
                },
                location: {
                    required: "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 digits long",
                    maxlength: "Your Mobile No. must be at least 10 digits long",
                }
            },
            submitHandler: function(form) {
                $.ajax({
                    url: '<?= site_url; ?>/enquiry_popup.php',
                    type: 'POST',
                    data: $('#enq_pop_form').serialize(),
                    dataType: 'json',
                    success: function(response) {
                        if (response.status == true) {
                            $('#enq_pop_up').text(response.message_response).css('color',
                                'green');
                            $('#enq_pop_form')[0].reset();
                            grecaptcha.reset();

                        } else {
                            $('#enq_pop_up').text(response.message_response).css('color',
                                'red');

                        }
                    }
                });

            }
        });


        $("#product_pop_form").validate({
            rules: {
                name: "required",
                message: {
                    required: true,

                },
                location: {
                    required: true,

                },
                email: {
                    required: true,

                },

                quantity: {
                    required: true,

                },

                mobile: {
                    required: true,
                    number: true,
                    minlength: 10,
                    maxlength: 10,
                }
            },
            messages: {
                name: "Please enter your name",
                message: {
                    required: "Please enter your message",

                },

                email: {
                    required: "Please enter your email address"
                },
                location: {
                    required: "Please Enter Your Location",

                },
                qunatity: {
                    required: "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 digits long",
                    maxlength: "Your Mobile No. must be at least 10 digits long",
                }
            },
            submitHandler: function(form) {
                $.ajax({
                    url: '<?= site_url; ?>/enquirycat_popup.php',
                    type: 'POST',
                    data: $('#product_pop_form').serialize(),
                    dataType: 'json',
                    success: function(response) {
                        if (response.status == true) {
                            $('#cat_pop_up').text(response.message_response).css('color',
                                'green');
                            $('#product_pop_form')[0].reset();
                            grecaptcha.reset();

                        } else {
                            $('#cat_pop_up').text(response.message_response).css('color',
                                'red');

                        }
                    }
                });

            }
        });

        $('#whatsEnq').click(function(e) {


            e.preventDefault();
            var wname = $('#wmname').val();
            var wmobile = $('#wmobile').val();
            $.ajax({
                url: "<?= site_url; ?>/whatsapp_enq.php",
                data: $('#contact_id').serialize(),
                type: "POST",
                success: function(data) {

                    if (data.trim() == 'success') {

                        $('#whatsapp_response').html('<div class="alert alert-success">Whatsapp Enquiry Submitted successfully</div>');
                        $('#whatsappEnq').trigger('reset');

                        window.open("https://api.whatsapp.com/send?phone=919810031296&text=&source=&data=&app_absent=", "_blank");

                    } else {

                        $('#whatsapp_response').html(data);
                    }
                }

            })

        })



        $("#callback_form").validate({
            rules: {
                name: "required",

                mobile: {
                    required: true,
                    number: true,
                    minlength: 10,
                }
            },
            messages: {
                name: "Please enter your name",
                mobile: {
                    required: "Please enter your mobile no.",
                    number: "Mobile No. contains only numbers",
                    minlength: "Your Mobile No. must be at least 10 characters long",
                }
            },
            submitHandler: function(form) {
                $.ajax({
                    url: '<?= site_url; ?>/ajax_enq_action.php',
                    type: 'POST',
                    data: $('#callback_form').serialize(),
                    dataType: 'json',
                    success: function(response) {
                        if (response.status == true) {
                            $('#cpop_up').text(response.message_response).css('color',
                                'green');
                            $('#callback_form')[0].reset();
                            grecaptcha.reset();

                        } else {
                            $('#cpop_up').text(response.message_response).css('color',
                                'red');

                        }
                    }
                });

            }
        });
    });
    function ValidateAlpha(evt) {
        var keyCode = (evt.which) ? evt.which : evt.keyCode
        if ((keyCode < 65 || keyCode > 90) && (keyCode < 97 || keyCode > 123) && keyCode != 32)
            return false;
        return true;
    }

    function isNumberKey(evt) {
        //var e = evt || window.event;
        var charCode = (evt.which) ? evt.which : evt.keyCode
        if (charCode != 46 && charCode > 31 &&
            (charCode < 48 || charCode > 57))
            return false;
        return true;
    }

    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 = "";
        }
    }
</script>