var l_popinDiv;

function hidePopin(in_divid) {
    $("#" + in_divid).fadeOut(300, function() {
        $("#popin_coverDiv").fadeOut(300, function() {
            if (document.getElementById(in_divid) != null) {
                document.body.removeChild(document.getElementById(in_divid));
            }

            $(".flash_content").show();
        });
    });
}

function showCover(in_width, in_height, in_divid) {
    var l_coverDiv = document.getElementById("popin_coverDiv")
    //$(".flash_content").hide();

    if (l_coverDiv == null) {
        l_coverDiv = document.createElement("DIV");
        l_coverDiv.id = "popin_coverDiv";
        document.body.appendChild(l_coverDiv);
        l_coverDiv.style.height = $(document).height() + "px";
        l_coverDiv.style.width = $(document).width() + "px";
        l_coverDiv.style.zIndex = 1000;
        l_coverDiv.style.position = "absolute";
        l_coverDiv.style.top = "0px";
        l_coverDiv.style.background = "black";

        $("#popin_coverDiv").css("opacity", .65);
    }

    $("#popin_coverDiv").fadeIn(300, function() { });

    l_popinDiv = document.getElementById(in_divid)

    if (l_popinDiv == null) l_popinDiv = document.createElement("DIV");

    l_popinDiv.id = in_divid
    l_popinDiv.style.display = "none";
    l_popinDiv.style.zIndex = 1001;
    $(l_popinDiv).css("position", "absolute");
    $(l_popinDiv).css("margin", "0 auto");
    $(l_popinDiv).css("height", in_height + "px");
    $(l_popinDiv).css("width", in_width + "px");

    document.body.appendChild(l_popinDiv);
}

function showPopin(in_page, in_width, in_height, in_divid) {
    showCover(in_width, in_height, in_divid);

    $(l_popinDiv).append('<iframe id="idFrame" scrolling="no" src="' + in_page + '" width="100%" height="100%" allowtransparency="true" frameborder="0"></iframe>');

    var l = (document.body.scrollWidth / 2) - (in_width / 2)

    $(l_popinDiv).css({ top: document.body.scrollTop + 150, left: l });

    $("#idFrame".document).ready(function() {
        $(l_popinDiv).fadeIn(900);
    });
}
