(function ($) {

  // For positioning the Footer
  var footerPosition = function () {
    $('#layout', document).css('height', 'auto');
    $('#layout', document).height($(document).height());
    var contentHeight = $('#header', document).outerHeight(true) + $('#content', document).outerHeight(true) + $('#footer', document).outerHeight(true);
    if (contentHeight < $('#layout', document).innerHeight()) {
      $('#footer', document).css({ bottom: 0, left: 0, position: 'absolute' });
    } else {
      $('#footer', document).css({ bottom: 'auto', left: 'auto', position: 'static' });
    }
  };

  var evenHeight = function () {
    var height = 0;
    $('#content, #aside').each(function () {
      height = $(this).height() > height ? $(this).height() : height;
    }).each(function () {
      $(this).height(height);
    });
  };

  $(document).ready(function () {

    // For styles dependent on JavaScript presence/lack of presence
    $(document).removeClass('js-false').addClass('js-true');

    evenHeight();
    footerPosition();
    $(window).bind('resize', footerPosition);
    
    $('head', document).append('<link rel="stylesheet" type="text/css" media="screen, projection" href="/css/extend.css"/>');

  });

  $(document).load(function () {
    evenHeight();
    footerPosition();
  });

})(jQuery);
