﻿var __cookie;
var __divname;


function ShowPopup(name, width, height, cookiename) {
    __cookie = cookiename;
    __divname = name;
    jQuery("#" + name).each(function() {
        var s_width = jQuery(window).width();
        var s_height = jQuery(window).height();
        var s_top = jQuery("#Body").scrollTop();
	

	jQuery("#Body").append("<div id='textpopupbg'></div>");
	jQuery("#textpopupbg").css("position", "absolute");
	jQuery("#textpopupbg").css("background-color", "#000000");
	jQuery("#textpopupbg").css("width", s_width);
	jQuery("#textpopupbg").css("height", s_height);
	jQuery("#textpopupbg").css("top", 0);
	jQuery("#textpopupbg").fadeTo(0, 0.7);
	jQuery("#textpopupbg").css("z-index", "1");
    jQuery("#textpopupbg").show();

        jQuery("#" + name).css("width", width);
        jQuery("#" + name).css("height", height);
        jQuery("#" + name).css("top", 0);

        jQuery("#" + name).css("top", (s_height / 2) - (height / 2) + (s_top / 2));
        jQuery("#" + name).css("left", (s_width / 2) - (width / 2));
        jQuery("#" + name).css("z-index", "10");
        jQuery("#" + name).show();

    });

    jQuery(window).resize(function() {
        jQuery("#textpopupbg").each(function() {
            var s_width = jQuery(window).width();
            var s_height = jQuery(window).height();
            var s_top = jQuery("#Body").scrollTop();

            jQuery("#" + name).css("width", width);
            jQuery("#" + name).css("height", height);
            jQuery("#" + name).css("top", 0);

            jQuery("#" + name).css("top", (s_height / 2) - (height / 2) + (s_top / 2));
            jQuery("#" + name).css("left", (s_width / 2) - (width / 2));

            jQuery("#textpopupbg").css("width", s_width);
            jQuery("#textpopupbg").css("height", s_height);
            jQuery("#textpopupbg").css("top", "0px");
            jQuery("#textpopupbg").css("left", "0px");

        });
    });
    jQuery(".PopupHide").click(function() {
        CreateCookie(cookiename, "Seen", 999999);
        jQuery("#" + name).hide();
	jQuery("#textpopupbg").hide();
        return false;
    });
}

function PopUpTextHide()
{
	//CreateCookie(__cookie, "Seen", 999999);
        jQuery("#" + __divname).hide();
	jQuery("#textpopupbg").hide();
}

function CreateCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}
