$(function() {
	initLightbox && initLightbox();
	$('h2:not(.no-index)').makeIndex('#menu', 'li');
});

jQuery.fn.makeIndex = function(sel, elt) {
  return this.each(function() {
   if (!$(this).attr('id'))
     $(this).attr('id', "ch_"+$(this).text().replace(/[^a-zA-Z0-9_-]/g, '_'));

   $(sel).append(
    $.create(elt).append(
     $.create('a', {href: '#'+$(this).attr('id')}).html(
      $(this).html()
     )
    )
   );
  });
};

jQuery.create = function (tag, parms, context) {
  return $(jQuery.extend((context||document).createElement(tag), parms));
}
