const parent = document.getElementById("at-sticky-bottom");
const child = document.getElementById("at-sticky-bottom-child");

window.addEventListener("scroll", function () {
var height = window.innerHeight - child.offsetHeight;
if (parent.getBoundingClientRect().top > window.innerHeight - child.offsetHeight) {
	child.style.position = "fixed";
	child.style.bottom = 0;
} else {
	child.style.position = "relative";
	child.style.bottom = "";
}
});

$(document).ready(function(){

    // var swiperX = new Swiper('.swiperA', {
    //      autoplay: {
	// 		delay: 5000,
	// 	  },
    //     loop: true,
    // });
    // swiperX.on('slideChangeTransitionEnd', function() {
    //     if (swiperX.realIndex == 1) {
    //         $("#indexremark").slideDown();
    //     }else{
    //         $("#indexremark").slideUp();
    //     }

    // });

    var goto;
    $('a').not('#theLNK').on('click', function () {
        if($(this).attr('data-href') != ''){
            goto = $(this).attr('data-href');
            $('.featherlight').find("#theLNK").attr('href',goto);
            if($(this).attr('data-featherlight') == '#disclaimer_model'){$('.featherlight-content').addClass('whte');}else{$('.featherlight-content').removeClass('whte');}
        }
    });
    $("body").on("click", '.featherlight .model_flex_g a', function() {
        if($(this).attr('data-href') != ''){
            var all = $.featherlight.opened();
            var first = all[0];
            first.close();
        }
    });

    // Lang
    $('.tc-lang').on('click', function () {
        var loca = document.location.href;
        if (loca.indexOf("/en/") >= 0) {
            document.location.href = document.location.href.replace('/en/','/tc/');
        }else if (loca.indexOf("/sc/") >= 0) {
            document.location.href = document.location.href.replace('/sc/','/tc/');
        }
    });
    $('.sc-lang').on('click', function () {
        var loca = document.location.href;
        if (loca.indexOf("/en/") >= 0) {
            document.location.href = document.location.href.replace('/en/','/sc/');
        }else if (loca.indexOf("/tc/") >= 0) {
            document.location.href = document.location.href.replace('/tc/','/sc/');
        }
    });
    $('.en-lang').on('click', function () {
        var loca = document.location.href;
        if (loca.indexOf("/tc/") >= 0) {
            document.location.href = document.location.href.replace('/tc/','/en/');
        }else if (loca.indexOf("/sc/") >= 0) {
            document.location.href = document.location.href.replace('/sc/','/en/');
        }
    });



});