function openDialog(width, height, innerHTML) {
    var el = document.createElement('div');
    var dims = getWindowSize();
    el.style.cssText = "position:absolute;border:3px ridge #e0e0ef;"
                        +"top:"+((dims[0]-height)/2)+"px;left:"+((dims[1]-width)/2)+"px;z-index:666;"
                        +"width:"+width+"px;height:"+height+"px;background:#f0f0ff;overflow:scroll";
    el.innerHTML = innerHTML;
    var bodyEl = document.getElementsByTagName('body')[0];
    bodyEl.appendChild(el);
    return el;
}

function closeDialog(el) {
    el.parentNode.removeChild(el);
    el = null;
    return false;
}

function dispMsgs() {
    var html = '<div>'
        +'[<a href="#" onclick="return closeDialog(this.parentNode.parentNode)">X</a>]'
        +'</div>'
        +'<table class="msgTable"><tr><th>Vy:</th><th>My:</th></tr>';
    var res = HTTPRequestSend('./srv.php?call[msglist]&r='+Math.random(),'sync');
    if (res.status!=200) {
        alert('chyba spojení');
        return false;
    }
    var data = res.data;
    for (var i=0; i < data.length; ++i) {
        html += '<tr style="border-bottom:1px solid #a0a0a0"><td>'+data[i].txt+'</td><td>';
        if (data[i].reply)
            html += data[i].reply;
        else
            html += '<i>zatím bez odpovědi</i>';
        html += '</td></tr>';
    }
    html += '</table>';
    openDialog(400, 300, html);
    return false;
}
