calcOffsetBottom: function (elem) { if (elem == 'window') { return $(window).scrollTop() + $(window).height(); } else { return $(elem).offset().top + $(elem).height() + Number($(elem).css('border-top-width').replace(/px$/, '')) + Number($(elem).css('border-bottom-width').replace(/px$/, '')) + Number($(elem).css('padding-top').replace(/px$/, '')) + Number($(elem).css('padding-bottom').replace(/px$/, '')); } },