function insertFootnotes() {  if(!document.getElementsByTagName) return; //object detection  var spans = document.getElementsByTagName('span');  var noteIndex = 1;  for(var i=0; i<spans.length; i++) {    if(spans[i].className == 'footnote') { //are we dealing with a footnote?      var note = spans[i];      var id = 'note-' + noteIndex++; //ID of the footnote <span>      var idAnchor = id + '-a'; //ID of the footnote <a> (to expand/collapse the note)           var tmpLinkText; //get the text to be linked      for(var j=0;j<note.childNodes.length; j++) {        if(note.childNodes[j].nodeName == '#text') {          var tmp = note.childNodes[j];          if(tmp.substringData && tmp.replaceData) { //more testing to prevent errors in bad browsers            while(true) { //remove trailing spaces              if(tmp.substringData(tmp.length-1,1) == ' ') {                tmp.replaceData(tmp.length-1,1,'');              }              else {                break;              }            }          }          tmpLinkText = tmp.nodeValue;          break;        }      }           var tmpNoteText; //get the text of the footnote      for(var j=0;j<note.childNodes.length;j++) {        if(note.childNodes[j].nodeName == 'SMALL') {          tmpNoteText = note.childNodes[j].innerHTML;          break;        }      }           var okToContinue = (tmpLinkText == '' || tmpNoteText == '') ? false : true; //make sure that we actually have the information we need      if(okToContinue) {        note.innerHTML = ''; //clear the span to be safe        var link = '<a href="javascript:expand(\''+idAnchor+'\',\''+id+'\')" id="'+idAnchor+'" title="Click to expand/collapse" class="expand">'+tmpLinkText+'</a>';        var noteText = '<span id="'+id+'" class="hidden"> <span class="expand">'+tmpNoteText+'</span></span>';        note.innerHTML = link + noteText;      }    }  }}function expand(aID,spanID) {  if(!document.getElementById) return; //error prevention  var anchor = document.getElementById(aID);  var footnote = document.getElementById(spanID);  footnote.className = (footnote.className == 'shown') ? 'hidden' : 'shown';  anchor.className = (anchor.className == 'expand') ? 'collapse' : 'expand';}