window.onload = scroller;

if (window.addEventListener)
{
	window.addEventListener('scroll', scroller, false);
}
else
{
	window.onscroll = scroller;
}

if (window.addEventListener)
{
	window.addEventListener('resize', scroller, false);
}
else
{
	window.onresize = scroller;
}

function getViewHeight()
{
	var viewHeight = (window.innerHeight) ? window.innerHeight : (document.documentElement.clientHeight > 0) ? document.documentElement.clientHeight : document.body.clientHeight; // Safari responds correctly to innerHeight only
	return viewHeight;
}

function getViewWidth()
{
	var viewWidth = (window.innerWidth) ? window.innerWidth : (document.documentElement.clientWidth > 0) ? document.documentElement.clientWidth : document.body.clientWidth; // Safari responds correctly to innerHeight only
	return viewWidth;
}

function scroller()
{
	document.getElementById('scrollSpacer').style.height = 90;
	scroller = document.getElementById('scroller');
	scroller.style.left = '0px';
	scroller.style.display = 'block';
	scroller.style.top = calcScrollerPos();
	scroller.style.width = getViewWidth();
}

function calcScrollerPos()
{
	var scrollTop = (window.pageYOffset) ? window.pageYOffset : (document.documentElement.scrollTop >= document.body.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop; // Safari responds correctly to pageYOffset only
	var viewHeight = (window.innerHeight) ? window.innerHeight : (document.documentElement.clientHeight > 0) ? document.documentElement.clientHeight : document.body.clientHeight; // Safari responds correctly to innerHeight only
	return (scrollTop + viewHeight - 68) + 'px';
}
