// Variables
var pageHeight;
var hHeight;
var nHeight;
var cHeight;
var bHeight;

// Document Ready Function
$(document).ready(function()
{
	//$('div.content').height(contentHeight+102);
	
	 $("ul.sf-menu").superfish();
	 
	// Hide the dropdown menu if it doesn't have children
	$('ul.sf-menu > li').find('ul').each(function() 
	{
		if($(this).find('li').length == 0)
		{
			$(this).parent().hide();	
		}
	});
	
	setHeight();
	setBannerWidth();
	
	$(window).resize(function()
	{
		setHeight();
		setBannerWidth();
	});
	
	if($('td.calendarCell', $('table')).length)
	{
		$('td.calendarCell', $('table')).each(function()
		{
			if($(this).children('a').length)
			{
				$(this).css('background', '#c8ebfa');	
			}
		});
	}
});

function setHeight()
{
	hHeight = $('div.header').outerHeight();
	nHeight = $('div.nav').outerHeight();
	cHeight = $('div.content').outerHeight();
	bHeight = $('body').height();
	
	if(cHeight == 0) cHeight = $('div.pageContent').outerHeight();
	
	//alert('content: ' + cHeight + ', hHeight: ' + hHeight + ', nHeight: ' + nHeight + ', bHeight: ' + bHeight);
	
	if((cHeight + nHeight + hHeight) > bHeight)
	{
		$('div.content').height(cHeight);
	}
	else
	{
		$('div.content').height(bHeight - nHeight - hHeight);
	}
}

function setBannerWidth()
{
	var pWidth = 0;
	
	$('div.photos').find('div.photo').each(function()
	{
		pWidth = pWidth + $(this).width();		
	});
	
	$('div.photos').width(pWidth);
}