﻿function custom_locationpath_ending() {

    var lp = document.getElementById('locationpath');
    var args = arguments;
    var odd = args.length % 2;

    if (lp !== null && args.length) {
        var lastchild = lp.lastChild;
        while ((lastchild !== null) && (lastchild.nodeName != "LI"))
            lastchild = lastchild.previousSibling;
        lp.removeChild(lastchild);

        for (var i = 0; i < args.length; i = i + 2) {
            var new_li = document.createElement("LI");
            if (args[i + 1]) {
                var new_href = document.createElement("A");
                new_href.setAttribute("href", args[i + 1]);
                new_href.innerHTML = args[i];
                new_li.appendChild(new_href);
            } else {
                new_li.innerHTML = args[i];
            }
            lp.appendChild(new_li);
        }
    }
}