var minHeight;
var pageWrapper;

$(window).load(function(){
	setMinimumPageHeight();	
	resizePDFCells();
});

function resizePDFCells(){
    $(".pdf-view-wrapper").each(function(){
        // get the parent cell's height
        var height = $(this).parent().outerHeight();
        // set the wrapper's height
        $(this).css('height',(height-11));
    });
}

function setMinimumPageHeight(){
	minHeight = 600;
	pageWrapper = $("#wrapper");
	
	// get size of #wrapper
	var pageHeight = pageWrapper.outerHeight();
	
	// make sure the wrapper is at least 500px tall
	if (pageHeight < minHeight){
		var height = minHeight+"px";
		pageWrapper.css('height', height).moveFooter();
	}
}

// get the footer's distance from the bottom
$.fn.moveFooter = function(){
	// pageWrapper's floor
	var floor = pageWrapper.offset().top + pageWrapper.outerHeight();
	
	// get the footer's floor
	var footer_floor = $("#footer").offset().top + $("#footer").outerHeight();
	
	// close the gap
	var gap = floor - footer_floor
	var footer_top_margin = parseInt($("#footer").css('margin-top'));
	
	// move the footer accordingly
	var new_top_margin = footer_top_margin + gap;
	$("#footer").css('margin-top',new_top_margin);
}

