jQuery(function ($)
  {
    // TODO Use :heading, http://github.com/jeresig/sizzle/issues#issue/16
    $(':header')
      .each(function ()
        {
          var selector = [];
          for (var level = 1; level <= this.tagName.slice(-1); level++)
          {
            selector.push('h' + level);
            selector.push(':has(h' + level + ')');
          }

          //$(this).nextUntil(selector.join(', '))
          //  .andSelf()
          //  .wrapAll('<section id="' + $(this).attr('id') + '"/>');
            //.wrapAll($(document.createElement('section')).attr('id', $(this).attr('id')));

	  // http://dev.jquery.com/ticket/6656
	  // http://dev.jquery.com/ticket/5327
	  // http://blogs.msdn.com/b/ie/archive/2010/06/10/same-markup-explaining-quot-jscript-version-quot-and-styling-new-html5-elements.aspx
	  $(document.createElement('section'))
	    .attr('id', $(this).attr('id'))
	    .insertBefore(this)
	    .append($(this).nextUntil(selector.join(', ')).andSelf());
        })
      .removeAttr('id');
  });
