﻿function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function setCookie(c_name, value, expireminutes) {
    var exdate = new Date();
    exdate.setTime(exdate.getTime() + expireminutes * 1000 * 60);
    document.cookie = c_name + "=" + escape(value) +
((expireminutes == null) ? "" : ";expires=" + exdate.toGMTString());
}

function checkCookie() {
    merrychristmas = getCookie('merrychristmas');
    if (merrychristmas != null && merrychristmas != "")
    { return false; }
    else {
        return true;
    }
}

function CloseChristmas() {
    var ad = document.getElementById("christmasAD");
    ad.style.display = "none";
    var adclose = document.getElementById("adclose");
    adclose.style.display = "none";
    setCookie("merrychristmas", "close", 3);

}
function OpenChristmas() {
       
    if (checkCookie()) {
        
        var ad = document.getElementById("christmasAD");
        ad.style.display = "";
        var adclose = document.getElementById("adclose");
        adclose.style.display = "";
    }
    else {
        
        CloseChristmas();
    }
}
