var obj,top,y,margin;
function init(id,m) {
	margin = m?m:100;
	if (document.getElementById) {
		obj =  document.getElementById(id);
		obj.style.position = 'absolute';
		y = top = obj.offsetTop;
		move();
	} 
}

function move() {
	var t = window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||window.pageYOffset||0;
	var wh = window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;
	var h = obj.offsetHeight;
	if(wh > margin*2+h){
		t = Math.max(t+margin,top);
	}else{
		var t1 = Math.max(t+margin,top);
		var u = t1>y?1:0;
		var t2 = t-h+wh-margin;
		var o = t2<y?1:0;
		u&&o?t=y:t=u?t2:t1;
	}
	y += (t-y)*0.25;
	obj.style.top = Math.floor(y)+'px';
	
	setTimeout('move()', 20);
}

