﻿var popUpHandler = function(elementId, cookie) {
    var popUpElement = document.getElementById(elementId);
    var cookieName = cookie;

    this.Init = function() {
        var c = this.getCookie(cookieName);
        if (c != null && c != "") {
            this.hide();
            //this.show();
        }
        else {
            this.setCookie(cookieName, cookieName, 365);
            this.show();
        }

    };

    this.setCookie = function(cn, value, expiredays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = cn + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toUTCString() + ";path=/;");
    };

    this.getCookie = function(cn) {
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(cn + "=");
            if (c_start != -1) {
                c_start = c_start + cn.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 "";
    };

    this.hide = function() {
        popUpElement.setAttribute('style', 'display:none;');
        popUpElement.style.display = "none";
    };

    this.show = function() {
        popUpElement.setAttribute('style', 'display:block;');
        popUpElement.style.display = "block";
    };
}

function InitPopUp() {
    var popUp = new popUpHandler("trpl_popUp", "trpl_popUp");
    
    try {
        var trplClose = document.getElementById("trpl_close");
        trplClose.onclick = popUp.hide;
    }
    catch (ex) { }
    popUp.Init();
}

var doPopUp = true;
