Report abuse


			
window.addEvent('domready',function(){
 print_footnotes();
});


function print_footnotes(){

  if($$('body a').length < 1){return;};

  var content_links =  $$('body a'); 
  var wrapper = document.body.getChildren().getLast();
  var print_notes = document.createElement('div');
  var notes_h1 = document.createElement('h1');
  var notes_title = document.createTextNode('offsite links:');
  var items_ol = document.createElement('ol');
  print_notes.className = 'print_only';
  print_notes.id = 'footnotes';
  wrapper.appendChild(print_notes);
    print_notes.appendChild(notes_h1);
      notes_h1.appendChild(notes_title);
    print_notes.appendChild(items_ol);

  var footnote_index = 0;

  content_links.each(function(link){

    var uri = link.getProperty('href');
    var dulynoted = false;

    $$('#footnotes li').each(function(footnote){
      if (footnote.innerHTML == uri){
        dulynoted = true;
        exisiting_footnote = footnote.getProperty('class');
        create_footnote(exisiting_footnote, false, false)
      };
    });

    if (dulynoted == false){
      footnote_index = footnote_index + 1;
      create_footnote(footnote_index, true, uri); 
    };

    function create_footnote(position, create, url){

      var footnote_super = document.createElement('sup');
      var super_content = document.createTextNode('['+ position +']');
      footnote_super.className = 'print_only';
      link.appendChild(footnote_super);
        footnote_super.appendChild(super_content);

      if (create == true){
        var item_li = document.createElement('li');
        item_li.className = position;
        var li_content = document.createTextNode(url);
        items_ol.appendChild(item_li);
         item_li.appendChild(li_content);
      };
    };
  });
};