jQuery.fn.background_fill = function() {
  return this.each(function(){
    var element = $(this);

    var background_image = element.css('background-image');
    if (background_image != 'none') {

      var match = background_image.match(/url\((.*)\)/); // grab what's between the url( ... )
      if (match != null) {
        background_image = match[1].replace(/['"]/, ''); // get rid of any quotes that may have been in the image url matched
      }
      // so the image can be absolutely positioned relative to this
      if (element.css('position') == 'static')
        element.css('position', 'relative');

      // so this element and the ones below it show up on TOP of the background image

      element.css('background-image', 'none');

      // see background-image css class for rules (this image will fill its parent)
      element.prepend('<img src="' + background_image + '" class="background-fill-image" />');
    }
  });
};

$(function(){

  $('.background-fill').background_fill(); // by default, run this on all .background-fill

});
