/* Sitewide Effects (requires jQuery) */
/* by White Whale Web Services for Kenyon College */

$(document).ready(function() { // document onload actions
	resize();
});

$(window).resize(resize); // when the window is resized, run resize();

function resize() { // actions to perform when the window is resized
	var width=$(window).width(), height=$(window).height();
	$('#masthead').css('height','auto'); // shrink the masthead to get it out of the way
	$('#wordmark_small').remove();
	$('#search').removeClass('inline');
 	if (width<900) {
		$('.twocolumns').addClass('combined');
		$('.twocolumns.withrule .first,.twocolumns.withrule .second').css('height','auto');
		if($('#container').width()>=940) $('#container').css('width','100%'); // if the browser doesn't respect #container's max-width	
	} else if (width>=900) {
		$('.twocolumns').removeClass('combined');
		$('.twocolumns.withrule .second').each(function() { if($(this).prev().height()>$(this).height()) $(this).height($(this).prev().height()); }); // make sure .twocolumns rule is full height
		if($('#container').width()>940) $('#container').css('width','900px'); // if the browser doesn't respect #container's max-width	
	}
	if(height<=430) $('#container').prepend('<img src="/Images/wordmark_small.png" width="169" height="26" alt="Kenyon College" id="wordmark_small"/>');
	if($('#navigation').width()>$('#container').width()-$('#search').width()) {
		$('#navigation').css('margin-top','2.5em');
		$('#search').addClass('inline');
		$('#wordmark_small').css('float','left');
	} else $('#navigation').css('margin-top','0');
	if($('#content').height()>$('#masthead').height()) $('#masthead').css('height',($('#content').height()-220)+'px');
}


