

$(document).ready(function() {
	
	if ($('#menu').size() > 0) {	// Если есть меню
		
		$('#menu li').each(function(i) {
			$(this).data('num', i);
		})
		
		aspenLeafSetPos($('#menu li.active'));
		
		$('#menu ul li a').hover(
			function() {
				aspenLeafSetPos($(this).parent());
			}, function() {
				aspenLeafSetPos($('#menu li.active'));
			}
		);
		
		
	}
	
	
	
	
	
	setFooterPosition();
	setInterval(setFooterPosition, 1000);
	
});



function setFooterPosition()
{
	
	var menu	= $('#menu');
	var content	= $('#content');
	
	var menuH		= (parseInt(menu.css('top')) + menu.height()) || 0;
	var contentH	= parseInt(content.css('top')) + content.height();
	
	
	pos = Math.max(menuH, contentH);
	
	
	$('#footer').css({top:pos + 'px', display: 'block'});
	
}

function aspenLeafSetPos(li)
{
	
	if (li.size() == 0) {	// Если нет выделенного пункта меню.
		$('#aspen-leaf').css('display', 'none');
		return;
	}
	
	
	var smechenieY	= -30;
	var itemH		= $('#menu li').height();
	var num			= li.data('num');
	
	
	var t = itemH * num + smechenieY;
	$('#aspen-leaf').css({ 'top' : t, 'display' : 'block' });
	
}
