/*
  faq.js - Generates an unordered list of the questions with links to 
  each, as well as top links before each question.
*/
document.observe("dom:loaded", function () {
  $$(".content h4:first-of-type").each( function(e) {
    e.insert({ before: new Element("ul", { "id": "faq" }) });
  });

  $$(".content h4").each( function(e, i) {
    $("faq").insert({ bottom: new Element("li")
                                         .update(new Element("a", { "href": getRelativePath() + "#" + i })
                                                            .update(e.innerHTML)) });

    e.insert({ before: new Element("a", { "class": "right", 
                                          "href": getRelativePath() + "#main_content" })
                                  .update("Top") });

    e.insert({ top: new Element("a", { "id": i, 
                                       "name": i }) });
  });
});
