$(function() {
var box = $('#messagelist'); // float-fixed block
var top = box.offset().top - parseFloat(box.css('marginTop').replace(/auto/, 0));
$(window).scroll(function(){
var windowpos = $(window).scrollTop();
if(windowpos < top) {
box.css('position', 'static');
} else {
box.css('position', 'fixed');
box.css('top', 0);
}
});
});
$(document).ready(function(){
var obj = $('#sticky');
var offset = obj.offset();
var topOffset = offset.top;
var marginTop = obj.css("marginTop");
$(window).scroll(function() {
var scrollTop = $(window).scrollTop();
if (scrollTop >= topOffset){
obj.css({
marginTop: 90,
position: 'fixed',
});
}
if (scrollTop < topOffset){
obj.css({
marginTop: 20,
position: 'relative',
});
}
});
});