 // 荣誉证书滚动按钮
document.addEventListener('DOMContentLoaded', function() {
    var newTrendsUl = document.querySelector('.new_trends_ul');
    var listItems = newTrendsUl.querySelectorAll('li'); // 获取所有的列表项
    var listItemWidth = newTrendsUl.firstElementChild.offsetWidth; // 假设所有列表项宽度相同
    var totalWidth = Array.from(listItems).reduce((acc, curr) => acc + curr.offsetWidth, 0); // 计算所有列表项的总宽度
    var visibleWidth = newTrendsUl.offsetWidth; // 可见宽度
    var currentScroll = 0; // 当前滚动位置
    var isScrolling = false; // 防止连续点击导致的快速滑动

    // 设置最大滚动距离，考虑循环滚动
    var maxScroll = totalWidth - visibleWidth;
    if (maxScroll < 0) {
        maxScroll = 0; // 如果没有足够的内容来滚动，则设置为0
    }

    // 左滑按钮点击事件
    document.querySelector('.new_trends_next').addEventListener('click', function() {
        if (!isScrolling && currentScroll > -totalWidth + visibleWidth) { // 考虑循环滚动的条件
            isScrolling = true;
            currentScroll -= listItemWidth;
            // if (currentScroll < -totalWidth + visibleWidth) { // 当滚动到列表末尾时，跳转到列表开始
            //     currentScroll = maxScroll;
            // }
            newTrendsUl.style.transform = 'translateX(' + currentScroll + 'px)';
            setTimeout(function() { isScrolling = false; }, 300); // 滑动结束后允许再次点击
        }
    });

    // 右滑按钮点击事件
    document.querySelector('.new_trends_prev').addEventListener('click', function() {
        if (!isScrolling && currentScroll < 0) {
            isScrolling = true;
            currentScroll += listItemWidth;
            if (currentScroll > maxScroll) { // 当滚动到列表开始时，跳转到列表末尾
                currentScroll = -totalWidth + visibleWidth;
            }
            newTrendsUl.style.transform = 'translateX(' + currentScroll + 'px)';
            setTimeout(function() { isScrolling = false; }, 300); // 滑动结束后允许再次点击
        }
    });
});

    // 显示弹窗的函数
function nex_sl_more_btn_1() {
  var popup = document.getElementById('popup');
  var overlay = document.getElementById('overlay');
  popup.style.display = 'block';
  overlay.style.display = 'block';
}

function close_pop() {
    var popup = document.getElementById('popup');
    var overlay = document.getElementById('overlay');
    popup.style.display = 'none';
    overlay.style.display = 'none';
  }
// 为链接添加点击事件监听器
document.getElementById('nex_sl_more_btn_1').addEventListener('click', function(event) {
  event.preventDefault(); // 阻止链接的默认行为
  nex_sl_more_btn_1(); // 显示弹窗
});

// 首页预约按钮
    // 显示弹窗的函数
function yuyue_shouye_1() {
  var popup_yuyue_1 = document.getElementById('popup_yuyue_1');
  var overlay = document.getElementById('overlay');
  popup_yuyue_1.style.display = 'block';
  overlay.style.display = 'block';
}

function close_pop_yuyue_1() {
    var popup_yuyue_1 = document.getElementById('popup_yuyue_1');
    var overlay = document.getElementById('overlay');
    popup_yuyue_1.style.display = 'none';
    overlay.style.display = 'none';
  }
// 为链接添加点击事件监听器
document.getElementById('yuyue_shouye_1').addEventListener('click', function(event) {
  event.preventDefault(); // 阻止链接的默认行为
  yuyue_shouye_1(); // 显示弹窗
});

// 资讯文章预约按钮
    // 显示弹窗的函数
function zixun_list_yuyue() {
  var popup_zixun_yuyue = document.getElementById('popup_zixun_yuyue');
  var overlay = document.getElementById('overlay');
  popup_zixun_yuyue.style.display = 'block';
  overlay.style.display = 'block';
}

function close_pop_zixun_yuyue() {
    var popup_zixun_yuyue = document.getElementById('popup_zixun_yuyue');
    var overlay = document.getElementById('overlay');
    popup_zixun_yuyue.style.display = 'none';
    overlay.style.display = 'none';
  }
// 为链接添加点击事件监听器
document.getElementById('zixun_list_yuyue').addEventListener('click', function(event) {
  event.preventDefault(); // 阻止链接的默认行为
  zixun_list_yuyue(); // 显示弹窗
});

// 资讯文章内容预约按钮
    // 显示弹窗的函数
function zixun_list_yuyue_news_1() {
  var popup_zixun_yuyue_news_1 = document.getElementById('popup_zixun_yuyue_news_1');
  var overlay = document.getElementById('overlay');
  popup_zixun_yuyue_news_1.style.display = 'block';
  overlay.style.display = 'block';
}

function close_pop_zixun_yuyue_news_1() {
    var popup_zixun_yuyue_news_1 = document.getElementById('popup_zixun_yuyue_news_1');
    var overlay = document.getElementById('overlay');
    popup_zixun_yuyue_news_1.style.display = 'none';
    overlay.style.display = 'none';
  }
// 为链接添加点击事件监听器
document.getElementById('zixun_list_yuyue_news_1').addEventListener('click', function(event) {
  event.preventDefault(); // 阻止链接的默认行为
  zixun_list_yuyue_news_1(); // 显示弹窗
});
