(function() {
	var $content, _offsetTop, _imgHeight, _minHeight, _newMarginTop;
	
	$(function() {
		$content = $('#content');
		_defaultTop = parseInt($content.css('marginTop'));
		_imgHeight = $content.find('.section img').height();
		_minHeight = 650;
		_newMarginTop = _offsetTop;
		
		var _offsetTop = $('#footer').offset().top;
		if (_offsetTop > _minHeight) {
			_newMarginTop = _defaultTop + Math.round((_offsetTop - _minHeight) / 2);
			$content.css('margin-top', _newMarginTop + 'px');
		} else {
			$content.css('margin-top', _defaultTop + 'px');
		}
	});
	
	$(window).resize(function() {
		var _offsetTop = $('#footer').offset().top;
		if (_offsetTop > _minHeight) {
			_newMarginTop = _defaultTop + Math.round((_offsetTop - _minHeight) / 2);
			$content.css('margin-top', _newMarginTop + 'px');
		} else {
			$content.css('margin-top', _defaultTop + 'px');
		}
	});
}).call(this);

