
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'); 
  $('#frontpage-middle').width(windowWidth);
  $('#frontpage-middle').height(windowHeight - 180);
  $('#aside').height(windowHeight - 200);
  $('#content-container').width(windowWidth - 430);
  $('#content-container').height(windowHeight - 180 + 30);
  $('#content-container #frontpage-text').width(windowWidth - 430 - 230);
  $('#bottom').width(windowWidth); 
  $('#bottom').css('top', windowHeight - 80);
}

function show() {
  $('#top').slideDown('slow');
  $('#bottom').slideDown('slow',
    function() {
      $('#logo').slideDown('slow', function() {
	    $('#label').slideDown('slow');
		$('#menu').slideDown('slow');
		$('#frontpage-middle').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);
  });
