function resizeContent(){
	// resize container
	var windowHeight = $(window).height();
	var mainContentHeight = $("#mainContent").height();
	var topPadding = 104;
	
	if((mainContentHeight+topPadding)<windowHeight){
		$("#mainContent").height(windowHeight);
	}
	// resize content/sidebar
	var sidebarHeight = $("#sidebar").height();
	mainContentHeight = $("#mainContent").height();

	if(mainContentHeight>sidebarHeight){
	//	$("#sidebar").height(mainContentHeight);
	}
	else if(sidebarHeight>mainContentHeight){
		$("#mainContent").height(sidebarHeight);
	}
	
	// move footer
	$("#mainContent").css("padding-bottom","15px");
	$("#siteFooter").css("bottom","5px");
	$("#siteFooter").css("right","10px");
	$("#siteFooter").css("position","absolute");
}

function showCalendarControls(){
	$(".smallCalendar h4").css("display","block");
	$(".smallCalendar .leftArrow, .smallCalendar .rightArrow").css("display","block");
}

function enableCalendarLightbox(){
	$(".smallCalendar td a").lightBox();
}

$(document).ready(function(){
	resizeContent();
	$(".thumbBox a").lightBox();
	$("#sidebar .flyerLink").lightBox();
	
	
	
	$(window).resize(function(){
			resizeContent();
	});
	$("#menu > ul").superfish();
	
	$("#menu a.pullDown").click(function(){
		return false;
	});
	
	showCalendarControls();
	enableCalendarLightbox();
	
	$(".smallCalendar .leftArrow").click(function(){
			var targetDate = $("#previousMonthVal").val();
			$.ajax({
				type: "GET",
				url: "/lib/php/calendar.php",
				data: 'date='+targetDate,
				success: function(data){
					$("#sidebarCalendar").html(data);
					showCalendarControls();
					enableCalendarLightbox();
				}
			});
			
			return false;
	});
	$(".smallCalendar .rightArrow").click(function(){
			var targetDate = $("#nextMonthVal").val();
			$.ajax({
				type: "GET",
				url: "/lib/php/calendar.php",          
				data: 'date='+targetDate,
				success: function(data){
					$("#sidebarCalendar").html(data);
					showCalendarControls();
					enableCalendarLightbox();
				}
			});
			
			return false;
	});
	
	$("#siteSearch .submit input").click(function(){
			alert("Search coming soon.");
			return false;
	});
});
