function getScreenTop ( obj )
{
	var top = 0;

	while(obj.offsetParent)
	{
		top += obj.offsetTop;
		obj = obj.offsetParent;
	}

	return top;
}

function resizeTop( contents_id , top_obj_id )
{
	var contents_obj = document.getElementById(contents_id);	
	var top_obj = document.getElementById(top_obj_id);

	top_obj.offsetParent.style.height = (contents_obj.offsetHeight) + "px";
}

function positionTop( contents_id , base_obj_id , top_obj_id )
{
	var contents_obj = document.getElementById(contents_id);	
	var base_obj = document.getElementById(base_obj_id);
	var top_obj = document.getElementById(top_obj_id);

	top_obj.style.top = base_obj.offsetHeight  + "px";
	top_obj.offsetParent.style.height = (contents_obj.offsetHeight) + "px";

	return base_obj.offsetHeight;
}

function MoveTopPosition( obj , now_top )
{
	var nx = parseInt(obj.style.top);

	if(obj["intervaleID"] != 0) clearInterval(obj["intervalID"]);

	if(nx != now_top)
	{
		obj["intervalID"] = setInterval( function () {
			nx += 0.07 * ( now_top - nx );
			var top = Math.round( nx );

			if( top == now_top )
			{			
				obj.style.top = now_top + "px";
				
				clearInterval(obj["intervalID"]);
				obj["intervalID"] = 0;
			}
			else
			{
				obj.style.top = top + "px";
			}
		}, 10 );
	}
}

function ScrollLayer( move_obj_id )
{
	var obj = document.getElementById(move_obj_id);

	var objheight = 13;	

	setInterval( function() {
		var top = 0;
		if (document.documentElement && document.documentElement.scrollTop)
			top = document.documentElement.scrollTop;
		else if (document.body && document.body.scrollTop)
			top = document.body.scrollTop;
				
		var clientHeight = 0;
		if (document.documentElement && document.documentElement.clientHeight)
			clientHeight = document.documentElement.clientHeight;
		else if (document.body && document.body.clientHeight)
			clientHeight = document.body.clientHeight;

		var now_top = getScreenTop(obj);
	//	now_top = top-now_top + 200;
		now_top = (clientHeight/2)-now_top+top - 100;
		now_top = parseInt(obj.style.top) + now_top;

		MoveTopPosition( obj, now_top );
	}, 100 );
}