﻿var slideTime = 700;
var floatAtBottom = false;
var isNav = navigator.appName == "Netscape";
function pepsi_floating_init() {
    xMoveTo('floating_banner_right', 960 - (1024 - screen.width), 0);

    winOnResize(); // set initial position
    xAddEventListener(window, 'resize', winOnResize, false);
    xAddEventListener(window, 'scroll', winOnScroll, false);
    if (screen.width >= 1280) {
        document.getElementById('floating_banner_right_content').style.display = '';
        document.getElementById('floating_banner_left_content').style.display = '';
    }
    else {
        document.getElementById('floating_banner_right_content').style.display = 'none';
        document.getElementById('floating_banner_left_content').style.display = 'none';
    }
}
function winOnResize() {
    checkScreenWidth();
    winOnScroll(); // initial slide
}
function winOnScroll() {
    var y = xScrollTop();
    if (floatAtBottom) {
        y += xClientHeight() - xHeight('floating_banner_left');
    }


    if (isNav) {
        xSlideTo('floating_banner_left', (screen.width - (970 - 775) - 770) / 2 - 150, y, slideTime);  // Chỉnh khoảng cách bên trái
        xSlideTo('floating_banner_right', (screen.width - (615 - 795) + 770) / 2, y, slideTime); // // Chỉnh khoảng cách bên Phải
    }
    else {
        xSlideTo('floating_banner_left', (screen.width - (975 - 775) - 770) / 2 - 150, y, slideTime);  // Chỉnh khoảng cách bên trái
        xSlideTo('floating_banner_right', (screen.width - (620 - 795) + 770) / 2, y, slideTime); // // Chỉnh khoảng cách bên Phải
    }
}

function checkScreenWidth() {
    if (document.body.clientWidth < 926) {
        document.getElementById('floating_banner_left').style.display = 'none';
        document.getElementById('floating_banner_right').style.display = 'none';
    }
    else {
        document.getElementById('floating_banner_left').style.display = '';
        document.getElementById('floating_banner_right').style.display = '';
    }
} 
