jQuery(document).ready(function ($) {
    $('#openPopup').on('click', function () {
        $('#header__popup').fadeIn();
    });

    $('#closePopup').on('click', function () {
        $('#header__popup').fadeOut();
    });

    $(document).on('click', function (e) {
        if ($(e.target).closest('.popup-content, #openPopup').length === 0) {
            $('#header__popup').fadeOut();
        }
    });
});


// language dropdown 
jQuery(document).ready(function($) {
    $('.menu__language.selected').click(function() {
        $('.language__dropdown').toggle();
    });

    $('.language__dropdown .menu__language').click(function() {
        var selectedImageSrc = $(this).find('img').attr('src');
        var selectedText = $(this).find('span').text();

        $('.menu__language.selected img').attr('src', selectedImageSrc);
        $('.menu__language.selected span').text(selectedText);

        $('.language__dropdown').hide();
    });

    $(document).click(function(event) {
        if (!$(event.target).closest('.menu__language-container').length) {
            $('.language__dropdown').hide();
        }
    });
});


jQuery(document).ready(function ($) {
    var header = $('.header__main');
    var stickyOffset = header.offset().top;

    $(window).scroll(function () {
        if ($(window).scrollTop() > stickyOffset) {
            header.addClass('sticky');
        } else {
            header.removeClass('sticky');
        }
    });
});

jQuery(document).ready(function ($) {
    var dateInput = $('#date');

    dateInput.attr('type', 'text');

    dateInput.focus(function () {
        $(this).attr('type', 'date');
    });

    dateInput.blur(function () {
        if (!$(this).val()) {
            $(this).attr('type', 'text');
        }
    });
});

var swiper = new Swiper(".mySwiper", {
    slidesPerView: 4,
    spaceBetween: 29,
    loop: true,
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
    navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev",
    },
    breakpoints: {
        320: {
            slidesPerView: 1,
            spaceBetween: 10,
        },
        525: {
            slidesPerView: 2,
            spaceBetween: 15,
        },
        768: {
            slidesPerView: 3,
            spaceBetween: 20,
        },
        1025: {
            slidesPerView: 4,
            spaceBetween: 29,
        }
    }
});

jQuery('video').click(function () {
    this[this.paused ? 'play' : 'pause']();
});

jQuery(document).ready(function ($) {
    $('.video__tag').on('click', function () {
        const video = $(this).find('.george')[0];
        if ($(this).hasClass("playicon")) {
            // $(this).removeClass("playicon");
        } else {
            $(this).addClass("playicon");
        }
        if (video.paused) {
            video.play();
        } else {
            video.pause();
        }
    });
});

var swiper = new Swiper(".news-Swiper", {
    slidesPerView: 2,
    grid: {
        rows: 2,
    },
    spaceBetween: 60,
    loop: true,
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
    navigation: {
        nextEl: ".custom-button-next",
        prevEl: ".custom-button-prev",
    },
    breakpoints: {
        320: {
            slidesPerView: 1,
            grid: {
                rows: 2,
            },
            spaceBetween: 30,
        },
        525: {
            slidesPerView: 1,
            grid: {
                rows: 2,
            },
            spaceBetween: 30,
        },
        991: {
            slidesPerView: 2,
            grid: {
                rows: 2,
            },
            spaceBetween: 30,
        },
        1025: {
            slidesPerView: 2,
            grid: {
                rows: 2,
            },
            spaceBetween: 60,
        }
    }
});


// map js 
function initMap() {
    var map = new google.maps.Map(document.getElementById("map"), {
        zoom: 5,
        center: { lat: 20.5937, lng: 78.9629 } // Centering on India
    });

    var locations = [
        {
            position: { lat: 28.6139, lng: 77.2090 }, // New Delhi
            content: `
                <div class="map__infowindow">
                    <div class="map-info__image">
                        <img src="images/87eae260b597947462f2a822e32c6691 (1).png" alt="New Delhi">
                    </div>
                    <div class="map-info__details">
                        <h6>Jetzt ganz of­fi­zi­ell: Hier ist es klar</h6>
                        <div class="stars">★★★★★</div>
                        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has.</p>
                    </div>
                </div>`
        },
        {
            position: { lat: 19.0760, lng: 72.8777 }, // Mumbai
            content: `
                <div class="map__infowindow">
                <div class="map-info__image">
                    <img src="images/87eae260b597947462f2a822e32c6691 (1).png" alt="New Delhi">
                </div>
                <div class="map-info__details">
                    <h6>Jetzt ganz of­fi­zi­ell: Hier ist es klar</h6>
                    <div class="stars">★★★★★</div>
                    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has.</p>
                </div>
                </div>`
        },
        {
            position: { lat: 12.9716, lng: 77.5946 }, // Bengaluru
            content: `
                <div class="map__infowindow">
                <div class="map-info__image">
                    <img src="images/87eae260b597947462f2a822e32c6691 (1).png" alt="New Delhi">
                </div>
                <div class="map-info__details">
                    <h6>Jetzt ganz of­fi­zi­ell: Hier ist es klar</h6>
                    <div class="stars">★★★★★</div>
                    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has.</p>
                </div>
                </div>`
        },
        {
            position: { lat: 22.5726, lng: 88.3639 }, // Kolkata
            content: `
                <div class="map__infowindow">
                <div class="map-info__image">
                    <img src="images/87eae260b597947462f2a822e32c6691 (1).png" alt="New Delhi">
                </div>
                <div class="map-info__details">
                    <h6>Jetzt ganz of­fi­zi­ell: Hier ist es klar</h6>
                    <div class="stars">★★★★★</div>
                    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has.</p>
                </div>
                </div>`
        },
        {
            position: { lat: 13.0827, lng: 80.2707 }, // Chennai
            content: `
                <div class="map__infowindow">
                <div class="map-info__image">
                    <img src="images/87eae260b597947462f2a822e32c6691 (1).png" alt="New Delhi">
                </div>
                <div class="map-info__details">
                    <h6>Jetzt ganz of­fi­zi­ell: Hier ist es klar</h6>
                    <div class="stars">★★★★★</div>
                    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has.</p>
                </div>
                </div>`
        }
    ];

    var currentInfoWindow = null;

    locations.forEach(function (location) {
        var marker = new google.maps.Marker({
            position: location.position,
            map: map
        });

        var infoWindow = new google.maps.InfoWindow({
            content: location.content
        });

        marker.addListener('click', function () {
            if (currentInfoWindow) {
                currentInfoWindow.close();
            }
            infoWindow.open(map, marker);
            currentInfoWindow = infoWindow;
        });
    });

    // Close info window when clicking on the map
    map.addListener('click', function () {
        if (currentInfoWindow) {
            currentInfoWindow.close();
        }
    });
}

window.onload = initMap;



jQuery(document).ready(function($) {
    $('.click__box').on('click', function() {
        $(this).find('a.target__click')[0].click();
    });
});

// jQuery(document).ready(function($){
//     var scroller = new SmoothScroll({
//         target: document.querySelector(".scroll-container"),
//         scrollEase: 0.05,
//     });
      
// });

// -----------------------------------------------------------------------------------




  