// Custom Javascript Functions Unique to this site

function initSidebar(skipResize){
	$('#sidebuckets img:last').css('marginBottom','0px');
	/*-----------------------------------------------------------------------*/
	/*	Calculating the height of the content area does not seem to work 
	/*	properly when using the Photo Galleries monklet due to the fact that
	/*	the eventual height of the <img> is NOT determined by the time this
	/*	function gets called (which is at "document ready"). So when viewing 
	/*	the Single Photo view of the Photo Galleries monklet, this calcuation
	/*	should be ignored...
	/*-----------------------------------------------------------------------*/
	if(!skipResize){
		if($('#content #text #photo').length == 0){
			var sidebarHeight = $('#sidebar').height();
			var contentOuterHeight = $('#content_outer').height();
			if(contentOuterHeight < sidebarHeight){
				var addHeight = sidebarHeight - contentOuterHeight;
				var contentHeight = $('#content').height();
				$('#content').css('height', (contentHeight + addHeight) + 'px');
			}
		}else{
			$('#content').css('minHeight','650px');	
		}
	}
	
	initEmptyNavs();
}

/*----------------------------------------------------------------*/
/*	Configures any 'empty' nav items (does not link to any page) in
/*	the sidebar navigation menu to expand their child <ul> on click
/*----------------------------------------------------------------*/
function initEmptyNavs(){
	$("#subnav li").each(function(i,elem){
		var id = $(elem).attr("id");
		var a = $("#subnav #"+id+" a:first");
		var href = $(a).attr("href");
		if(href == "#"){
			$(a).attr("nav_id", id);
			$(a).unbind("click");
			$(a).click(function(){
				var id = $(this).attr("nav_id");
				var currentDisplay = $("#subnav #"+id+" ul:first").css('display');
				$("#subnav ul ul:first").slideUp('fast', function(){
					if(currentDisplay == 'none'){
						$("#subnav #"+id+" ul:first").slideDown();
					}
				});
			});
		}
	});
}