String.prototype.toInteger = function() {
	return this.replace(/[^0-9]/g, '') * 1;
}

function follow_banner(div_id, origin_top, limit_top, margin_top)
{
	var d, t, s, g, target_height;
	origin_top *= 1;
	limit_top *= 1;
	margin_top *= 1;

	d = document.getElementById(div_id);
	s = document.body.scrollTop + "";

	target_height = s.toInteger() + margin_top;
	if(target_height < limit_top) {
		target_height = origin_top;
	}

	t = d.style.top.toInteger();

	if(t != target_height) {
		g = Math.ceil((t - target_height) / 2);
		if(g > 30) {
			g = 30;
		} else if (g < -30) {
			g = -30;
		}
		d.style.top = (t - g) + "px";
	}

	setTimeout("follow_banner('" + div_id + "', " + origin_top + ", " + limit_top + ", " + margin_top + ");", 10);
}

