<a class="whatapp_btn" href="#" data-bs-toggle="modal" data-bs-target="#whatsapp" title="Whatsapp Now"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">

        <path d="M13.601 2.326A7.854 7.854 0 0 0 7.994 0C3.627 0 .068 3.558.064 7.926c0 1.399.366 2.76 1.057 3.965L0 16l4.204-1.102a7.933 7.933 0 0 0 3.79.965h.004c4.368 0 7.926-3.558 7.93-7.93A7.898 7.898 0 0 0 13.6 2.326zM7.994 14.521a6.573 6.573 0 0 1-3.356-.92l-.24-.144-2.494.654.666-2.433-.156-.251a6.56 6.56 0 0 1-1.007-3.505c0-3.626 2.957-6.584 6.591-6.584a6.56 6.56 0 0 1 4.66 1.931 6.557 6.557 0 0 1 1.928 4.66c-.004 3.639-2.961 6.592-6.592 6.592zm3.615-4.934c-.197-.099-1.17-.578-1.353-.646-.182-.065-.315-.099-.445.099-.133.197-.513.646-.627.775-.114.133-.232.148-.43.05-.197-.1-.836-.308-1.592-.985-.59-.525-.985-1.175-1.103-1.372-.114-.198-.011-.304.088-.403.087-.088.197-.232.296-.346.1-.114.133-.198.198-.33.065-.134.034-.248-.015-.347-.05-.099-.445-1.076-.612-1.47-.16-.389-.323-.335-.445-.34-.114-.007-.247-.007-.38-.007a.729.729 0 0 0-.529.247c-.182.198-.691.677-.691 1.654 0 .977.71 1.916.81 2.049.098.133 1.394 2.132 3.383 2.992.47.205.84.326 1.129.418.475.152.904.129 1.246.08.38-.058 1.171-.48 1.338-.943.164-.464.164-.86.114-.943-.049-.084-.182-.133-.38-.232z"></path>

    </svg></a>

<a href="#" data-bs-toggle="modal" data-bs-target="#myModal" class="send_enquiry" title="Send Enquiry"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">

        <path d="M.05 3.555A2 2 0 0 1 2 2h12a2 2 0 0 1 1.95 1.555L8 8.414.05 3.555ZM0 4.697v7.104l5.803-3.558L0 4.697ZM6.761 8.83l-6.57 4.027A2 2 0 0 0 2 14h12a2 2 0 0 0 1.808-1.144l-6.57-4.027L8 9.586l-1.239-.757Zm3.436-.586L16 11.801V4.697l-5.803 3.546Z"></path>

    </svg><span>Send Enquiry</span></a>



<a href="tel:+91-123-456-7890" class="call_now" title="+91-123-456-7890"><span class="fa fa-phone"></span></a>

<?php include "app_modal.php"; ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/wow/1.0.2/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/jquery-validate/1.9.0/jquery.validate.min.js"></script>
<script src="<?= site_url; ?>/designer/js/intlTelInputWithUtils.js"></script>
<script src="<?= site_url; ?>/designer/js/themes.js"></script>

<script>
    setTimeout(function() {
        $.getScript("https://www.google.com/recaptcha/api.js");
    }, 5000);

    /* WhatsApp Form Validation*/
    $(document).ready(function() {
        function setupPhoneValidation(formId) {
            if (typeof window.intlTelInput !== "function") {
                console.error("intlTelInput library is not loaded.");
                return;
            }

            const inputFields = document.querySelectorAll(formId + " .telePhone");

            inputFields.forEach(input => {
                const iti = window.intlTelInput(input, {
                    initialCountry: "pk",
                    allowDropdown: true,
                    useFullscreenPopup: false,
                    separateDialCode: false,
                    utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/25.2.1/js/utils.min.js",
                });

                function updateHiddenFields() {
                    const selectedCountry = iti.getSelectedCountryData();
                    const codeInput = document.querySelector(formId + " .code");
                    const countryNameInput = document.querySelector(formId + " .countryName");

                    if (codeInput) codeInput.value = `${selectedCountry.dialCode}`; // Adding plus sign
                    if (countryNameInput) countryNameInput.value = selectedCountry.name;

                    updatePhoneValidation(formId, input, selectedCountry);
                }

                updateHiddenFields(); // Set initial values

                input.addEventListener("countrychange", updateHiddenFields);
            });
        }

        function updatePhoneValidation(formId, input, countryData) {
            let validator = $(formId).data("validator");
            if (!validator) return;

            let fieldName = $(input).attr("name");
            $(input).rules("remove"); // Remove previous validation rules

            if (countryData.iso2 === "pk") {
                $(input).attr({
                    maxlength: 10,
                    minlength: 10
                });
                $(input).rules("add", {
                    required: true,
                    number: true,
                    minlength: 10,
                    maxlength: 10,
                    messages: {
                        required: "Mobile number is required",
                        minlength: "Indian mobile number must be exactly 10 digits long",
                        maxlength: "Indian mobile number must be exactly 10 digits long",
                    }
                });

            } else if (countryData.iso2 === "in") {
        $(input).attr({
            maxlength: 10,
            minlength: 10
        });
        $(input).rules("add", {
            required: true,
            number: true,
            minlength: 10,
            maxlength: 10,
            messages: {
                required: "Mobile number is required",
                minlength: "Indian mobile number must be exactly 10 digits long",
                maxlength: "Indian mobile number must be exactly 10 digits long",
            }
        });

            } else {
                $(input).attr({
                    maxlength: 17,
                    minlength: 4
                });
                $(input).rules("add", {
                    required: true,
                    number: true,
                    minlength: 4,
                    maxlength: 17,
                    messages: {
                        required: "Mobile number is required",
                        minlength: "Your Mobile No. must be at least 4 digits long",
                        maxlength: "Your Mobile No. must be at most 17 digits long",
                    }
                });
            }

            $(input).valid(); // Trigger validation check
        }

        if (typeof window.intlTelInput === "function") {
            setupPhoneValidation("#whatsapp_form");
        } else {
            console.error("intlTelInput is not loaded. Check your script includes.");
        }

        if (typeof $.fn.validate === "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 Numeric",
                        minlength: "Mobile Number must have 10 digits",
                        maxlength: "Mobile Number must have 10 digits",
                    },
                },
            });
        } else {
            console.error("jQuery Validate is not loaded. Check your script includes.");
        }
    });

    $('#whatsapp_form').submit(function(e) {
        e.preventDefault();
        $(':input[type="submit"]').prop('disabled', true);
        $.ajax({
            'url': '<?= site_url; ?>/whatsapp_enq.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)
                    $(':input[type="submit"]').prop('disabled', false);
                } 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');
                    $(':input[type="submit"]').prop('disabled', false);
                }
            }
        });
    });
    /* WhatsApp Form Validation*/


    /*enq_pop_form1 */
    $(document).ready(function() {
        function setupPhoneValidation(formId) {
            if (typeof window.intlTelInput !== "function") {
                console.error("intlTelInput library is not loaded.");
                return;
            }

            const inputVacations = document.querySelectorAll(formId + " .telePhone");

            inputVacations.forEach(input => {
                const iti = window.intlTelInput(input, {
                    initialCountry: "pk",
                    allowDropdown: true,
                    separateDialCode: false,
                    useFullscreenPopup: false,
                    utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/25.2.1/js/utils.min.js",
                });

                // Set initial validation rules for India
                const selectedCountry = iti.getSelectedCountryData();
                updatePhoneValidation(formId, input, selectedCountry);

                input.addEventListener("countrychange", function() {
                    const selectedCountry = iti.getSelectedCountryData();

                    // Ensure elements exist before updating them
                    const codeInput = document.querySelector(formId + " input.code");
                    const countryNameInput = document.querySelector(formId + " input.countryName");

                    if (codeInput) codeInput.value = `${selectedCountry.dialCode}`; // Adding plus sign
                    // if (codeInput) codeInput.value = selectedCountry.dialCode;
                    if (countryNameInput) countryNameInput.value = selectedCountry.name;

                    updatePhoneValidation(formId, input, selectedCountry);
                });
            });
        }

        function updatePhoneValidation(formId, input, countryData) {
            let validator = $(formId).data("validator");
            if (!validator) return;

            let fieldName = $(input).attr("name");

            if (countryData.iso2 === "pk") {
                $(input).attr("maxlength", 10);
                $(input).attr("minlength", 10);
                validator.settings.rules[fieldName] = {
                    required: true,
                    minlength: 10,
                    maxlength: 10
                };
                validator.settings.messages[fieldName] = {
                    required: "Mobile number is required",
                    minlength: "Indian mobile number must be exactly 10 digits long",
                    maxlength: "Indian mobile number must be exactly 10 digits long",
                };
            } else if (countryData.iso2 === "in") {
        $(input).attr({
            maxlength: 10,
            minlength: 10
        });
        $(input).rules("add", {
            required: true,
            number: true,
            minlength: 10,
            maxlength: 10,
            messages: {
                required: "Mobile number is required",
                minlength: "Indian mobile number must be exactly 10 digits long",
                maxlength: "Indian mobile number must be exactly 10 digits long",
            }
        });
            } else {
                $(input).attr("maxlength", 17);
                $(input).attr("minlength", 4);
                validator.settings.rules[fieldName] = {
                    required: true,
                    minlength: 4,
                    maxlength: 17
                };
                validator.settings.messages[fieldName] = {
                    required: "Mobile number is required",
                    minlength: "Your Mobile No. must be at least 4 digits long",
                    maxlength: "Your Mobile No. must be at most 17 digits long",
                };
            }

            $(input).valid(); // Trigger validation check
        }

        // Ensure intlTelInput is loaded before running setup
        if (typeof window.intlTelInput === "function") {
            setupPhoneValidation("#enq_pop_form1");
        } else {
            console.error("intlTelInput is not loaded. Check your script includes.");
        }

        // Validate form only if jQuery Validate is available
        if (typeof $.fn.validate === "function") {
            $("#enq_pop_form1").validate({
                rules: {
                    name: "required",
                    message: {
                        required: true
                    },
                    location: {
                        required: true
                    },
                    email: {
                        required: true
                    },
                    mobile: {
                        required: true,
                        number: true,
                        minlength: 10, // Default for India
                        maxlength: 17,
                    },
                },
                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 most 17 digits long",
                    },
                },
                submitHandler: function(form) {
                    $.ajax({
                        url: '<?= site_url; ?>/enquiry_popup.php',
                        type: "POST",
                        data: $("#enq_pop_form1").serialize(),
                        dataType: "json",
                        success: function(response) {
                            if (response.status === true) {
                                $("#enq_pop_up").text(response.message_response).css("color", "green");
                                $("#enq_pop_form1")[0].reset();
                                grecaptcha.reset();
                            } else {
                                $("#enq_pop_up").text(response.message_response).css("color", "red");
                            }
                        },
                    });
                }
            });
        } else {
            console.error("jQuery Validate is not loaded. Check your script includes.");
        }
    });

    /* enq_pop_form1*/


    /*product_pop_form */


    $(document).ready(function() {
        function setupPhoneValidation(formId) {
            if (typeof window.intlTelInput !== "function") {
                console.error("intlTelInput library is not loaded.");
                return;
            }

            const inputVacations = document.querySelectorAll(formId + " .telePhone");

            inputVacations.forEach(input => {
                const iti = window.intlTelInput(input, {
                    initialCountry: "pk",
                    allowDropdown: true,
                    separateDialCode: false,
                    useFullscreenPopup: false,
                    utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/25.2.1/js/utils.min.js",
                });

                // Set initial validation rules for India
                const selectedCountry = iti.getSelectedCountryData();
                updatePhoneValidation(formId, input, selectedCountry);

                input.addEventListener("countrychange", function() {
                    const selectedCountry = iti.getSelectedCountryData();

                    // Ensure elements exist before updating them
                    const codeInput = document.querySelector(formId + " input.code");
                    const countryNameInput = document.querySelector(formId + " input.countryName");

                    if (codeInput) codeInput.value = `${selectedCountry.dialCode}`; // Adding plus sign

                    if (countryNameInput) countryNameInput.value = selectedCountry.name;

                    updatePhoneValidation(formId, input, selectedCountry);
                });
            });
        }

        function updatePhoneValidation(formId, input, countryData) {
            let validator = $(formId).data("validator");
            if (!validator) return;

            let fieldName = $(input).attr("name");

            if (countryData.iso2 === "pk") {
                $(input).attr("maxlength", 10);
                $(input).attr("minlength", 10);
                validator.settings.rules[fieldName] = {
                    required: true,
                    minlength: 10,
                    maxlength: 10
                };
                validator.settings.messages[fieldName] = {
                    required: "Mobile number is required",
                    minlength: "Indian mobile number must be exactly 10 digits long",
                    maxlength: "Indian mobile number must be exactly 10 digits long",
                };
            } else if (countryData.iso2 === "in") {
        $(input).attr({
            maxlength: 10,
            minlength: 10
        });
        $(input).rules("add", {
            required: true,
            number: true,
            minlength: 10,
            maxlength: 10,
            messages: {
                required: "Mobile number is required",
                minlength: "Indian mobile number must be exactly 10 digits long",
                maxlength: "Indian mobile number must be exactly 10 digits long",
            }
        });
            } else {
                $(input).attr("maxlength", 17);
                $(input).attr("minlength", 4);
                validator.settings.rules[fieldName] = {
                    required: true,
                    minlength: 4,
                    maxlength: 17
                };
                validator.settings.messages[fieldName] = {
                    required: "Mobile number is required",
                    minlength: "Your Mobile No. must be at least 4 digits long",
                    maxlength: "Your Mobile No. must be at most 17 digits long",
                };
            }

            $(input).valid(); // Trigger validation check
        }

        // Ensure intlTelInput is loaded before running setup
        if (typeof window.intlTelInput === "function") {
            setupPhoneValidation("#product_pop_form");
        } else {
            console.error("intlTelInput is not loaded. Check your script includes.");
        }

        // Validate form only if jQuery Validate is available
        if (typeof $.fn.validate === "function") {
            $("#product_pop_form").validate({
                rules: {
                    name: "required",
                    message: {
                        required: true
                    },
                    location: {
                        required: true
                    },
                    quantity: {
                        required: true
                    },
                    email: {
                        required: true
                    },
                    mobile: {
                        required: true,
                        number: true,
                        minlength: 10, // Default for India
                        maxlength: 17,
                    },
                },
                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"
                    },
                    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 digits long",
                        maxlength: "Your Mobile No. must be at most 17 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");
                            }
                        },
                    });
                }
            });
        } else {
            console.error("jQuery Validate is not loaded. Check your script includes.");
        }
    });

    /*product_pop_form */

    /* Call back */
    $(document).ready(function() {
        function setupPhoneValidation(formId) {
            if (typeof window.intlTelInput !== "function") {
                console.error("intlTelInput library is not loaded.");
                return;
            }

            const inputVacations = document.querySelectorAll(formId + " .telePhone");

            inputVacations.forEach(input => {
                const iti = window.intlTelInput(input, {
                    initialCountry: "pk",
                    allowDropdown: true,
                    separateDialCode: false,
                    useFullscreenPopup: false,
                    utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/25.2.1/js/utils.min.js",
                });

                // Set initial validation rules
                const selectedCountry = iti.getSelectedCountryData();
                updatePhoneValidation(formId, input, selectedCountry);

                input.addEventListener("countrychange", function() {
                    const selectedCountry = iti.getSelectedCountryData();

                    // Ensure elements exist before updating them
                    const codeInput = document.querySelector(formId + " input.code");
                    const countryNameInput = document.querySelector(formId + " input.countryName");

                    if (codeInput) codeInput.value = `${selectedCountry.dialCode}`;
                    if (countryNameInput) countryNameInput.value = selectedCountry.name;

                    updatePhoneValidation(formId, input, selectedCountry);
                });
            });
        }

        function updatePhoneValidation(formId, input, countryData) {
            let validator = $(formId).data("validator");
            if (!validator) return;

            let fieldName = $(input).attr("name");

            if (countryData.iso2 === "pk") {
                $(input).attr("maxlength", 10);
                $(input).attr("minlength", 10);
                validator.settings.rules[fieldName] = {
                    required: true,
                    minlength: 10,
                    maxlength: 10
                };
                validator.settings.messages[fieldName] = {
                    required: "Mobile number is required",
                    minlength: "Indian mobile number must be exactly 10 digits long",
                    maxlength: "Indian mobile number must be exactly 10 digits long",
                };
            } else if (countryData.iso2 === "in") {
        $(input).attr({
            maxlength: 10,
            minlength: 10
        });
        $(input).rules("add", {
            required: true,
            number: true,
            minlength: 10,
            maxlength: 10,
            messages: {
                required: "Mobile number is required",
                minlength: "Indian mobile number must be exactly 10 digits long",
                maxlength: "Indian mobile number must be exactly 10 digits long",
            }
        });
            } else {
                $(input).attr("maxlength", 17);
                $(input).attr("minlength", 4);
                validator.settings.rules[fieldName] = {
                    required: true,
                    minlength: 4,
                    maxlength: 17
                };
                validator.settings.messages[fieldName] = {
                    required: "Mobile number is required",
                    minlength: "Your Mobile No. must be at least 4 digits long",
                    maxlength: "Your Mobile No. must be at most 17 digits long",
                };
            }

            $(input).valid(); // Trigger validation check
        }

        // Ensure intlTelInput is loaded before running setup
        if (typeof window.intlTelInput === "function") {
            setupPhoneValidation("#callback_form");
        } else {
            console.error("intlTelInput is not loaded. Check your script includes.");
        }

        // Validate form only if jQuery Validate is available
        if (typeof $.fn.validate === "function") {
            $("#callback_form").validate({
                rules: {
                    name: "required",
                    mobile: {
                        required: true,
                        number: true,
                        minlength: 10, // Default for India
                        maxlength: 17,
                    },
                },
                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 digits long",
                        maxlength: "Your Mobile No. must be at most 17 digits 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");
                            }
                        },
                    });
                }
            });
        } else {
            console.error("jQuery Validate is not loaded. Check your script includes.");
        }
    });
    /*Call Back */

/* Contact page Form*/

$(document).ready(function() {
        function setupPhoneValidation(formId) {
            if (typeof window.intlTelInput !== "function") {
                console.error("intlTelInput library is not loaded.");
                return;
            }

            const inputFields = document.querySelectorAll(formId + " .telePhone");

            inputFields.forEach(input => {
                const iti = window.intlTelInput(input, {
                    initialCountry: "pk",
                    allowDropdown: true,
                    separateDialCode: false,
                    utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/25.2.1/js/utils.min.js",
                });

                const selectedCountry = iti.getSelectedCountryData();
                updatePhoneValidation(formId, input, selectedCountry);

                input.addEventListener("countrychange", function() {
                    const selectedCountry = iti.getSelectedCountryData();

                    // Update country dial code and country name in hidden fields
                    const codeInput = document.querySelector(formId + " .code");
                    const countryNameInput = document.querySelector(formId + " .countryName");

                    if (codeInput) codeInput.value = `${selectedCountry.dialCode}`; // Adding plus sign
                    if (countryNameInput) countryNameInput.value = selectedCountry.name;

                    updatePhoneValidation(formId, input, selectedCountry);
                });
            });
        }

        function updatePhoneValidation(formId, input, countryData) {
            let validator = $(formId).data("validator");
            if (!validator) return;

            let fieldName = $(input).attr("name");

            if (countryData.iso2 === "pk") {
                $(input).attr("maxlength", 10);
                $(input).attr("minlength", 10);
                validator.settings.rules[fieldName] = {
                    required: true,
                    minlength: 10,
                    maxlength: 10
                };
                validator.settings.messages[fieldName] = {
                    required: "Mobile number is required",
                    minlength: "Indian mobile number must be exactly 10 digits long",
                    maxlength: "Indian mobile number must be exactly 10 digits long",
                };
            } else if (countryData.iso2 === "in") {
        $(input).attr({
            maxlength: 10,
            minlength: 10
        });
        $(input).rules("add", {
            required: true,
            number: true,
            minlength: 10,
            maxlength: 10,
            messages: {
                required: "Mobile number is required",
                minlength: "Indian mobile number must be exactly 10 digits long",
                maxlength: "Indian mobile number must be exactly 10 digits long",
            }
        });
            } else {
                $(input).attr("maxlength", 17);
                $(input).attr("minlength", 4);
                validator.settings.rules[fieldName] = {
                    required: true,
                    minlength: 4,
                    maxlength: 17
                };
                validator.settings.messages[fieldName] = {
                    required: "Mobile number is required",
                    minlength: "Your Mobile No. must be at least 4 digits long",
                    maxlength: "Your Mobile No. must be at most 17 digits long",
                };
            }

            $(input).valid(); // Trigger validation check
        }

        // Ensure intlTelInput is loaded before running setup
        if (typeof window.intlTelInput === "function") {
            setupPhoneValidation("#contact_form");
        } else {
            console.error("intlTelInput is not loaded. Check your script includes.");
        }

        // Validate form only if jQuery Validate is available
        if (typeof $.fn.validate === "function") {
            $("#contact_form").validate({
                rules: {
                    name: "required",
                    message: {
                        required: true
                    },
                    location: {
                        required: true
                    },
                    email: {
                        required: true,
                        email: true
                    },
                    mobile: {
                        required: true,
                        number: true,
                        minlength: 10, // Default for India
                        maxlength: 17,
                    },
                },
                messages: {
                    name: "Please enter your name",
                    message: {
                        required: "Please enter your message"
                    },
                    email: {
                        required: "Please enter your email address",
                        email: "Enter a valid 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 most 17 digits long",
                    },
                },
                submitHandler: function(form) {
                    $.ajax({
                        url: '<?= site_url; ?>/contact.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");
                            }
                        },
                    });
                }
            });
        } else {
            console.error("jQuery Validate is not loaded. Check your script includes.");
        }
    });
    /*Contact Page Form */

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


    //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>