﻿var slideTime = 600;
var floatAtBottom = false;

function pepsi_floating_init()
{
	

	winOnResize(); // set initial position
	xAddEventListener(window, 'resize', winOnResize, false);
	xAddEventListener(window, 'scroll', winOnScroll, false);
}
function winOnResize() {
	checkScreenWidth();
	winOnScroll(); // initial slide
}
function winOnScroll() {
  var y = xScrollTop() + 50;
  if (floatAtBottom) {
    y += xClientHeight() - xHeight('floating_banner_left');
  }
  
  xSlideTo('floating_banner_left', (screen.width - (800-775) - 770)/2-90 , y, slideTime); 
  /*==> floating_banner_left = (screen.width - (800-778) - 770)/2-115 (Ở đây, bạn có thể tăng giá trị : 115, thì fép tính nó sẽ đưa ra con số nhỏ của giá trị x, và banner trái nó sẽ chạy về bên tay trái.

==> floating_banner_right = (screen.width - (800-778) + 770)/2, bạn có thể cộng thêm 1 giá trị nào đó để tăng giá trị x cho banner phải. Ví dụ: (screen.width - (800-778) + 770)/2 + (giá trị muốn cho nó tăng thêm).*/
}
	
function checkScreenWidth()
{
	if( document.body.clientWidth < 926 )
	{	
		document.getElementById('floating_banner_left').style.display = 'none';
		
	}
	else
	{
		document.getElementById('floating_banner_left').style.display = '';
		
	}
}

pepsi_floating_init();
