// Custom Javascript Functions Unique to this site

function initSideNavigation(){
	$('#subnav li li:last').css('border','0 none');
	initEmptyNavs();
	if($('#content #text #photo').length != 0 || $('#adv_evite').length != 0){
		$('#content').css('minHeight','450px');
	}else{
		resizeContent();
	}
}

function resizeContent(){
	var sidebarHeight = $('#sidebar').outerHeight(false); // full height plus padding (exclude margins)
	sidebarHeight += 40; // add padding for the space above and below the sidebar relative to the content wrapper
	var wrapperHeight = $('#content_wrapper').outerHeight(false); // full height plus padding (exclude margins)
	if(wrapperHeight < sidebarHeight){
		var diff = sidebarHeight - wrapperHeight;
		$('#content').css('paddingBottom', diff + 'px');
	}
}

/*----------------------------------------------------------------*/
/*	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();
					}
				});
			});
		}
	});
}
