$(document).ready(function(){
	center_vertical();
	//center_services_grid();
});
$(window).resize(function(){
	center_vertical();
	//center_services_grid();
});

function center_vertical(){

	// Hide main container so that it doesn't add to the overall height
	$('.section-main .main-container').css({
		'display': 'none',
		'height': 0,
		'overflow': 'hidden',
		'margin-top': 0
	});

	var height = {};
	
	// Get the document height and the height of all the sections
	height.document = $(document).height();
	height.header = $('.section-header').outerHeight(true);
	height.extra = $('.section-extra').outerHeight(true);
	height.footer = $('.section-footer').outerHeight(true);
	
	// Calculate the remaining height
	height.remaining = height.document - (height.header + height.extra + height.footer);
	
	//console.log(height.remaining);
	
	// Show the main container and get its height
	$('.section-main .main-container').css({
		'display': '',
		'height': '',
		'overflow': ''
	});
	height.main = $('.section-main .main-container').outerHeight();
	
	if(height.main < height.remaining && height.main > 0){
	
		$('.section-main .main-container').css({
			'margin-top': (height.remaining - height.main) / 2
		});
	
	}
}

function center_services_grid(){
	$('#block-views-Services-block_3').css({
		'float': 'left',
		'margin-bottom': 16,
		'margin-right': 16
	});
}
