$(document).ready(function() {
  positionFooter();
});

$(window).resize(positionFooter)

//Footer
function positionFooter(){
	var textcontent = $(".text").height() + $(".headline").height()+65+10;
	var padding_top = $("#background_foot").css("margin-top").replace("px", "");
	var page_height = $("body").height();
	var window_height = $(window).height();
	var difference = window_height - page_height;
	
	//alert(difference);
	
	if(textcontent > page_height)
	{
		$("#background_content").css("height", textcontent);
	}
	else
	{
		if(difference < 0) 
			difference = 0;
		$("#space").css("height", difference);
	}
}

//Pagelinks
positionPagelinks();
function positionPagelinks() {
	var content_height = $(".content_right").height();
	var pagelink_height = $(".pagelinks").height();
	var text_height = $(".text").height();
	var headline_height = $(".headline").height();
	
	var space = content_height - (text_height + pagelink_height + pagelink_height + headline_height + 10);
	$(".pagelinks").css({
		margin: space + "px 0 0 0"
	});
}
		
