/* ##########################
 * # White Pages JS         #
 * #                        #
 * # Handles portal changes #
 * # to the H1's with first #
 * # css class              #
 * ########################## */

// let's make this into a function so it can be called elsewhere if needed
// function to convert h1's to having it's children in spans
function convertH1() {
    // get all h1s in the document
    var h1 = document.getElementsByTagName('h1');

    // go through all elements
    for(var i = 0; i < h1.length; i++) {
        // local var referencing the current h1
        var currentH1 = h1[i];

        // check if the element has the 'first' class
        if(currentH1.className == 'first') {
            // save the childnodes
            var childNodes = currentH1.childNodes;

            // create the span
            var span = document.createElement('span');
            for(var j = 0; j < childNodes.length; j++) {
                var node = childNodes[j]; // current node

                // only move text nodes
                if(node.tagName == undefined) {
                    // move the childnodes into the span
                    span.appendChild(node);
                }
            }
            // add the span to the h1
            currentH1.appendChild(span);
        }
    }
}
