function set_height() {
	var wh = $(window).height();
	var ch = Math.max($("div#sub_nav_container").height(),$("div#content_container").height());
	
	if ((ch+240+80) < wh) {
		$("div#inner_container").css("min-height", (wh-(240+80)) + "px");
	}
}

$(document).ready(function(){
	$(window).bind('resize', function() {
		set_height();
	});
	
	$("div#sub_nav_container.frontpage ul li a.toggle").click(function(event){
		var clicked_element = this;
		if ($(this).parent().find("ul").is(":hidden")) {
			$("div#sub_nav_container.frontpage ul li ul").each(function(){
				var element = this;
				if (!$(this).is(":hidden")) {
					$(this).slideUp("slow");
					$(this).parent().find("a.toggle").removeClass("hide");
					$(this).parent().find("a.toggle").addClass("show");
				}
			});
			$(clicked_element).parent().find("ul").slideDown("slow");
			$(clicked_element).removeClass("show");
			$(clicked_element).addClass("hide");
		} else {
			$(clicked_element).parent().find("ul").slideUp("slow");
			$(clicked_element).removeClass("hide");
			$(clicked_element).addClass("show");
		}
	});

	$("div#sub_nav_container.frontpage ul li a.hide").click(function(event){
		$(this).parent().find("ul").slideUp("slow");
	});
	
	$("a").click(function(event){
		var href = this.href;
		if((href.indexOf("jpg") != -1) || (href.indexOf("jpeg") != -1) || (href.indexOf("png") != -1) || (href.indexOf("gif") != -1)) {
			event.preventDefault();
			$.dimScreen(100, 0.8, function() {
				$('div#img_popup_container').css('top', $(window).scrollTop() + 'px');
				$('div#img_popup_container').fadeIn("fast", function() {
					$('div#img_popup_container').css('background', 'url(' + href + ') no-repeat center center');
				});
			});
		}
	});
		
	$("a#img_popup_close").click(function(event){
		event.preventDefault();
		$('div#img_popup_container').fadeOut("fast", function(){
			$('div#img_popup_container').css('background', 'none');
			$('#__dimScreen').remove();
		});
	});

	$(window).scroll(function() {
	  $('div#img_popup_container').animate({
			top: $(window).scrollTop() + 'px'
		},{queue: false, duration: 100});
	  $('div#__dimScreen').animate({
			top: $(window).scrollTop() + 'px'
		},{queue: false, duration: 100});
	});
});