var divisionx = 33.333;
var newdivisionx;

function fitToWindow() {
	
	$('#scroll').css({
		'height' : (document.documentElement.clientHeight - 60)+'px',
		'zIndex' : 10
	});
	
	var vertCenter = $('#main, #navContainer, div.case-study');
	var textOffset = $('#content .text').offset();
	
	if (textOffset.top <= 20) {
		var mainOffset = $('#main').offset();
		var newOffset = mainOffset.top + Math.abs(textOffset.top - 20);
		$(vertCenter).css('top',newOffset+'px');
	}
	else if ((document.documentElement.clientHeight * .52) < 380) {
		$(vertCenter).css('top','380px');
	} else {
		$(vertCenter).css('top','52%');
	}
}

$(document).ready(function(){
	
	fitToWindow();
	
	$(window).resize(function(){
		fitToWindow();
	});
	
	$('#open_facebook').click(function() {
		if ($('#facebook').css('display') == 'block') $('#facebook').fadeOut(200);
		else {
			$('#twitter').fadeOut(200);
			$('#facebook').fadeIn(400);
		}
		return false;
	});
	
	$('#open_twitter').click(function() {
		if ($('#twitter').css('display') == 'block') $('#twitter').fadeOut(200);
		else {
			$('#facebook').fadeOut(200);
			$('#twitter').fadeIn(400);
		}
		return false;
	});
	
});