var gZIndex2 = 1;
function dexalert2(data, title, w, h, id) {
    if (!id)
        id = Math.random();
    //mask
    var mask = document.createElement('div');

    mask.id = 'popupMask' + id;
    mask.className = 'popupMask';

    pBody = document.body;

    var fullHeight = document.viewport.getHeight();
    var fullWidth = document.viewport.getWidth();

    // Determine what's bigger, scrollHeight or fullHeight / width
    if (fullHeight > pBody.scrollHeight) {
        popHeight = fullHeight;
    } else {
        popHeight = pBody.scrollHeight
    }

    mask.style.height = popHeight + "px";
    mask.style.width = pBody.scrollWidth + "px";

    mask.style.opacity = "0.40"; // firefox miatt
    mask.style.filter = "alpha(opacity=40)"; // ie miatt

    mask.style.backgroundColor = "Black";
    mask.style.position = "absolute";
    mask.style.zIndex = gZIndex2++;
    mask.style.top = "0px";
    mask.style.left = "0px";
    mask.style.display = "block";

    mask.onclick = function() { closedexalert2(id); };

    pBody.appendChild(mask);

    var popup = document.createElement('div');
    popup.id = "popupDialog" + id;

    var pBody = document.body;

    if (typeof w == 'undefined')
    //w = fullWidth - 150;
        w = 700;
    if (typeof h == 'undefined')
        h = 400;
    //h = fullHeight - 150;

    var left = Math.round(fullWidth / 2 - w / 2);
    var top = Math.round(fullHeight / 2 - h / 2);
    if (left < 0)
        left = 0;
    if (top < 0)
        top = 0;
    if (typeof (window.pageYOffset) != 'undefined')
        top += window.pageYOffset
    else
        top += document.documentElement.scrollTop;

    popup.style.position = "absolute";
    popup.style.zIndex = gZIndex2++;
    popup.style.top = "0px";
    popup.style.left = "0px";
    /////popup.style.display = "none";
    //popup.style.opacity = "1.0";

    popup.style.top = top + "px";
    popup.style.left = left + "px";

    popup.style.width = w + "px";
    popup.style.height = h + "px";

    //'<a href=javascript:windowClose(' + id + ')>Bezárás</a>' +

    popup.innerHTML =
'<div class="dexalert"><div class="dexalert1"><div class="dexalerth"><a href="javascript:;" onclick="closedexalert2(\'' + id + '\');" style="float:right;margin-top: 12px; margin-right: 8px;"><img src="res/pics/x2.gif" border="0"/></a>' + title + '</div><div class="dexalertc" style="overflow-y: scroll;height: ' + (h - 34) + 'px">'
    //+ '<span style="position: absolute;"><a style="position: relative; top: 20px; left: 850px;" href=javascript:windowClose(' + id + ')>Bezárás</a></span>'
    + data + '</div></div></div>';

    pBody.appendChild(popup);

    //opacity(mask, 0, 40, 5000);
    //fadeIn(mask, 0, 40, 2);
    //resizeUp(popup, 100, 400, 20);

    //fadeIn(popup, 0, 100, 30, 20);
    //fadeIn(mask, 0, 40, 11, 20);

    //return id;
}
function closedexalert2(id) {
    var win = document.getElementById("popupMask" + id);
    win.parentNode.removeChild(win);
    win = document.getElementById("popupDialog" + id);
    win.parentNode.removeChild(win);
}
