$( document ).ready ( function ()
	{
		var rowWidth = parseInt ( $( "#box" ).css ( "width" )) - 4;
		var tabEnds = parseInt ( $( ".left" ).css ( "width" )) + parseInt ( $( ".right" ).css ( "width" ));
		var totalOpenWidth = rowWidth - ( 3 * tabEnds );

		$( ".row" ).each ( function ()
			{
				var tab_1 = parseInt ( $( this ).children ( ".center" ).children ().width());
				var tab_2 = parseInt ( $( this ).children ( ".center" ).next ().next ().next ().children ().width());
				var tab_3 = parseInt ( $( this ).children ( ".center" ).next ().next ().next ().next ().next ().next ().children ().width());

				var tabWidth = Math.floor (( totalOpenWidth - ( tab_1 + tab_2 + tab_3 )) / 3 );
				var tab_1_width = tabWidth + tab_1;
				var tab_2_width = tabWidth + tab_2;
				var tab_3_width = totalOpenWidth - tab_1_width - tab_2_width;

 				$( this ).children ( ".center" ).css ( "width", tab_1_width + "px" );
 				$( this ).children ( ".center" ).next ().next ().next ().css ( "width", tab_2_width + "px" );
 				$( this ).children ( ".center" ).next ().next ().next ().next ().next ().next ().css ( "width", tab_3_width + "px" );
			}
		);
	}
);

$( document ).ready ( function ()
	{
		$( window ).resize ( setTopMargin );
		setTopMargin ();
	}
);

function setTopMargin () {
	var boxHeight = parseInt ( $( "#box" ).height ());
	var topMargin = ( $( window ).height() - boxHeight ) / 2;
	topMargin = ( topMargin < 20 ) ? 20 : topMargin ;
	$( "body" ).css ( "marginTop", topMargin + "px" )
}
