/*globals  $$, window, document */

"use strict";

/** This function retrieves the list of div tags in the page and calls the
  * getFootnote function with the list of div tags as input. */

function assembleFootnote() {
    var tagList,
    footnoteNumbering,
    i;
    tagList = [];
    //Retrieving the list of div tags in the page 
    tagList = document.getElementsByTagName("span");
    footnoteNumbering = 0;
    for (i = 0; i < tagList.length; i += 1) {
        //Check if the id is 'footnote'
        if (tagList[i].getAttribute('id') === 'footnote') {
            // Increment the footnote number and update in the inner HTML
            footnoteNumbering += 1;
            tagList[i].innerHTML = "<sup>" + footnoteNumbering + "</sup>";

        }
    }
}

/* This function takes the div ID's and collapses/expands its content. */

function expandCollapse(disclaimerId, expandCollapseId) {
    var obj,
    col,
    b,
    e,
    scrollHeight,
    bodyHeight;
    
    if (document.getElementById("wrapper_Nav") !== null) {
    	document.getElementById("wrapper_Nav").style.height = 1 + 'px';
    }    
    
    obj = document.getElementById(disclaimerId);
    col = document.getElementById(expandCollapseId);
    b = document.body;
    e = document.documentElement;
    scrollHeight = 0;
    bodyHeight = 0;

    if (obj.style.display === "none" || obj.style.display === "") {
        obj.style.display = "block";
        col.innerHTML = "- ";
    } else {
        obj.style.display = "none";
        col.innerHTML = "+ ";
    }

    if (e) {
        scrollHeight = e.scrollHeight - 150;
        bodyHeight = e.offsetHeight;
    } else if (b) {
        scrollHeight = b.scrollHeight - 150;
        bodyHeight = b.offsetHeight;
    }
    if (document.getElementById("wrapper_Nav") !== null) {
        document.getElementById("wrapper_Nav").style.height = scrollHeight + 'px';
    }

}