﻿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);
        }
    }
}

function setCookie(c_name, value, exdays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
    c_value += "; path=/";
    document.cookie = c_name + "=" + c_value;
}

function getCookie(c_name) {
    var i, x, y, ARRcookies = document.cookie.split(";");
    for (i = 0; i < ARRcookies.length; i++) {
        x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
        x = x.replace(/^\s+|\s+$/g, "");
        if (x == c_name) {
            return unescape(y);
        }
    }
}

function set_surveyseen() {
    setCookie('surveyseen', 1, 365);
}

function sg_popup() {
    var surveyseen = getCookie('surveyseen');
    if (!surveyseen) 
    {
        document.getElementById('sg-popup').style.display = 'block';
    }
}

function body_on_load() {
    sg_popup();
}
