function footerheigh() {
          
        function setFooter() {
			var documentheight = $(window).height();
			var globalheight = $("#global_home").height();
			var globalposition = $("#global_home").offset();
			var footerheight = $("#footer").outerHeight();
			
			var positionfooter = globalposition.top + globalheight;
			
			if((positionfooter + footerheight)>documentheight){
				$("#footer").css("top", positionfooter + "px");
			}else{
				$("#footer").css("top", (documentheight - footerheight) + "px");
			}
     
        }
        window.onload = function() {
            setFooter();
        }
        window.onresize = function() {
            setFooter();
        }
}

footerheigh();
