(function ($) {

/**
 * 'Sticky Footer' by Peter Anderson
 * Inspired by: http://www.drupalcoder.com/blog/cross-browser-sticky-footer-with-fluid-height-using-jquery
 *
 * Edited to work with background images - adds padding to bottom of content,
 * rather than margin to top of footer.
 */
Drupal.behaviors.stickyFooter = {
  attach: function (context, settings) {

    // Set 'body' element
    var content = $('#main-wrapper');

    // Make footer sticky on page load and when resizing the window
    makeSticky(content);
    $(window).resize(function() {
      makeSticky(content);
    });

  }
};

function makeSticky(content) {
  // Reset the content's bottom padding to correctly calculate the heights
  content.css('padding-bottom', '0');

  // Get body and window heights
  var bodyHeight = $(document.body).height();
  var windowHeight = $(window).height();

  if (bodyHeight < windowHeight) {
    // Calculate the difference in heights
    var diff = windowHeight - bodyHeight;

    // Set the content's bottom padding
    content.css('padding-bottom', diff);
  }
}

}(jQuery));
;

