function initBudTowerBanner() {
	window.onscroll = function() {
		repositionLeftTowerBanner();
		repositionRightTowerBanner();
		repositionLeftSitehatBanner();
		repositionRightSitehatBanner()
	}
	repositionLeftTowerBanner();
	repositionRightTowerBanner();
	repositionLeftSitehatBanner();
	repositionRightSitehatBanner();
}

function repositionRightTowerBanner() {
	var pageLocationX = findPos( document.getElementById("page") )[0];
	var topOffset = document.documentElement.scrollTop > 0 ? document.documentElement.scrollTop : document.body.scrollTop;

	var bannerElem = document.getElementById('rightTowerBanner');
	if ( bannerElem ) {
		bannerElem.style.top = topOffset + 'px';
		bannerElem.style.left = (pageLocationX + 984)+"px";
		bannerElem.style.display = "";
	}
}

function repositionLeftTowerBanner() {
	var pageLocationX = findPos( document.getElementById("page") )[0];
	var topOffset = document.documentElement.scrollTop > 0 ? document.documentElement.scrollTop : document.body.scrollTop;

	var bannerElem = document.getElementById('leftTowerBanner');
	if ( bannerElem ) {
		bannerElem.style.top = topOffset + 'px';
		bannerElem.style.left = (pageLocationX - 120)+"px";
		bannerElem.style.display = "";
	}
}

function repositionRightSitehatBanner() {
	var page = document.getElementById("page");
	var pageLocationX = findPos( page )[0];
	var pageWidth = page.offsetWidth;
	var topOffset = document.documentElement.scrollTop > 0 ? document.documentElement.scrollTop : document.body.scrollTop;
	
	var bannerElem = document.getElementById('rightSitehatBanner');
	if ( bannerElem ) {
		bannerElem.style.height = getBodyHeight() + "px";
		bannerElem.style.width = (( getBodyWidth() - pageWidth ) / 2)  + "px";
		bannerElem.style.left = (pageLocationX + pageWidth)+"px";
	}
}

function repositionLeftSitehatBanner() {
	var page = document.getElementById("page");
	var pageLocationX = findPos( document.getElementById("page") )[0];
	var pageWidth = page.offsetWidth;
	var topOffset = document.documentElement.scrollTop > 0 ? document.documentElement.scrollTop : document.body.scrollTop;
	
	var bannerElem = document.getElementById('leftSitehatBanner');
	if ( bannerElem ) {
		bannerElem.style.height = getBodyHeight() + "px";
		bannerElem.style.width = (( getBodyWidth() - pageWidth ) / 2)  + "px";
		var currentWidth = bannerElem.offsetWidth;
		bannerElem.style.left = (pageLocationX - currentWidth) + "px";
		
	}
}


function getBodyWidth() {
	 var D = document;
    return Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}

function getBodyHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		do
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
		while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}


