var _ad,_adTop,_maxScroll,_lastPos=0;
window.onload = init;
function init() {
	_ad = document.getElementById('right-banner');
	_end = document.getElementById('content-box');
	_ad.style.position = 'absolute';
	adLeft = document.body.scrollWidth - 122;

	_ad.style.left = adLeft + 'px';
	_ad.style.left = adLeft + 'px';

	_adTop = 5;
	_ad.style.top = _adTop + 'px';
	_maxScroll = document.getElementById('content-box').offsetHeight;
	_lastPos = 0; // -999
	adScroll();
	_ad.style.visibility  = 'visible';

}
function pos() {
	if (window.innerHeight)return window.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) return document.documentElement.scrollTop;
	else if (document.body) return document.body.scrollTop;
}

function adScroll() {
        // document.getElementById('footer').innerHTML = "adtop: " + _adTop + " " + " pos: " + pos() + " maxscroll " + _maxScroll + " main " ;
	if ( _lastPos != pos()) {
		_lastPos = pos();
		if (pos() > _adTop) _ad.style.top = pos() + 'px';
		else if (pos() > _maxScroll) _ad.style.top = _maxScroll;
		else  _ad.style.top = _adTop + 'px';
		
	}
	setTimeout('adScroll();',10);

}
