
function animateLink(li) {
  $(li).addClass('animating');
  $('.menu-link').css('color', 'white');
  $(li).css('position', 'relative');
  $(li).css('bottom', '-25px');
  $(li).animate({bottom: 15}, 100);
  $(li).animate({bottom: 0}, 100, function() {
    $('.menu-link').css('color', 'white');
    $(li).children('.menu-link').css('color', '#fe8100'); 
	$(li).removeClass('animating'); 
	});
}

function adjustMarkup() {
  var windowWidth = $(window).width();
  if (windowWidth < 900) // 900 - min width
    windowWidth = 900;
  var windowHeight = $(window).height();
  if (windowHeight < 500) // 500 - min height
    windowHeight = 500;
  $('#top').width(windowWidth);
  $('#label').css('left', (300 + (windowWidth - 300) / 2 - 250) + 'px'); 
  $('#middle').width(windowWidth);
  $('#middle').height(windowHeight - 180);
  $('#aside').height(windowHeight - 180);
  $('#content-container').width(windowWidth - 300);
  $('#content-container').height(windowHeight - 180 + 30);
  $('#bottom').width(windowWidth); 
  $('#bottom').css('top', windowHeight - 80);
}

function show() {
  $('#top').show();
  $('#middle').show();
  $('#bottom').show();
  $('#menu').show();
  //
  $('.menu-link-container').mouseenter(function() {
    if ($(this).hasClass('animating') || $(this).hasClass('mouse-in')) 
	  return;
	$('.menu-link-container').removeClass('mouse-in');
	$(this).addClass('mouse-in');
	animateLink(this);
  });
  $('.menu-link-container').mouseleave(function() {
    if ($(this).hasClass('animating')) 
	  return;
	$(this).removeClass('mouse-in');
	$(this).children('.menu-link').css('color', 'white'); });
}

$(document).ready(function() {
  adjustMarkup();
  show();
  $(window).resize(adjustMarkup);
  });

