<script>
$(document).ready(function() {
setInterval(function() {
var docHeight = $(window).height();
var footerHeight = $('#footer').height();
var footerTop = $('#footer').position().top + footerHeight;
var marginTop = (docHeight - footerTop + 10);
if (footerTop < docHeight)
$('#footer').css('margin-top', marginTop + 'px'); // padding of 30 on footer
else
$('#footer').css('margin-top', '0px');
// console.log("docheight: " + docHeight + "
" + "footerheight: " + footerHeight + "
" + "footertop: " + footerTop + "
" + "new docheight: " + $(window).height() + "
" + "margintop: " + marginTop);
}, 250);
});
</script>