$(function() {
	// Setup
	var container = $("#con_contents");
	var scrollable = $(".btn_ptop");
	// From here don't touch
	scrollable.each(function(){
		var container_offset = container.offset();
		var scrollable_offset = scrollable.offset();
		var limit, target;
		$(window).scroll(function() {
			if ($(window).scrollTop() > scrollable_offset.top) {
				target = $(window).scrollTop() - scrollable_offset.top;
				limit = (container.outerHeight() + container_offset.top) - (scrollable.outerHeight() + scrollable_offset.top + 10);
				if (target > limit) target = limit;
			} else {
				target = 0;
			};
			$(".btn_ptop").stop().animate({
				marginTop: target
			});
		});
		$(window).scroll();
	});
});
