jQuery(document).ready(setHeight);

function setHeight(){
    var $overlays = $('.center-center');
    $overlays.each(function(){
        var $overlay = $(this);
        var $table = $overlay.children("table:eq(0)");
        var tableHeight = $table.height();
        var bodyHeight = $('body').height();
        var screenHeight = screenSize().h;
        if(tableHeight > bodyHeight){
            $overlay.css('height',tableHeight);
        }
        else{
            $overlay.css('height',bodyHeight);
        }
        if($overlay.height() < screenHeight){
            $overlay.css('height',screenHeight);
        }
        if(tableHeight < $overlay.height())
        {
            if( screenHeight > tableHeight )
            {
                $table.css('margin-top',Math.ceil((screenHeight - tableHeight)/2));
            }
        }
    });
}

function screenSize() {
	var w, h;
	w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
	h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
	return {w:w, h:h};
}
