// Window load event used just in case window height is dependant upon images
$(window).ready(function() {

       var footerHeight = 0,
           footerTop = 0,
           $footer = $("#footer");

       positionFooter();

       function positionFooter() {

                footerHeight = $footer.height() + parseInt($footer.css("padding-top"), 10) + parseInt($footer.css("padding-bottom"), 10);
                footerTop = ($(window).scrollTop()+$(window).height()-footerHeight)+"px";

               if ( ($("#main").height()+$("#header").height()+$("#footer").height()+200) < $(window).height()) {
                   $footer.css({
                        position: "absolute",
						top: footerTop
                   })
               } else {
                   $footer.css({
                        position: "static"
                   })
               }

       }

       $(window)
               .scroll(positionFooter)
               .resize(positionFooter)

});
