var nw_shade,nw_app,nw_ptable,nw_newprompt;
function init_parentobj() {
    nw_newprompt = parent.document.createElement('div');
    nw_newprompt.id = 'AutoPostPrompt';
    nw_newprompt.className = 'PromptWord';
    nw_newprompt.innerHTML="<span>&nbsp;</span>";
    parent.document.body.insertBefore(nw_newprompt, parent.document.getElementById('Head'));
}
function getPosXY(pw_obj, offset) {
    var posxy = offset ? offset.slice(0) : [0,0],obj_tn;
    while (pw_obj) {
        obj_tn = pw_obj.tagName.toUpperCase();
        posxy[0] += pw_obj.offsetLeft - (obj_tn == "DIV" && pw_obj.scrollLeft ? pw_obj.scrollLeft : 0);
        posxy[1] += pw_obj.offsetTop - (obj_tn == "DIV" && pw_obj.scrollTop ? pw_obj.scrollTop : 0);
        if (obj_tn == "BODY") break;
        pw_obj = pw_obj.offsetParent;
    }
    return posxy;
}
function show_newwindiv() {
    init_parentobj();
    nw_shade = parent.document.createElement('div');
    nw_shade.id = 'PromptShade';
    parent.document.body.insertBefore(nw_shade, parent.document.getElementById('Head'));
    nw_app = parent.document.getElementById('AutoPostPrompt');
    nw_ptable = parent.document.getElementById('PromptWord');
    var position = function() {
        if (nw_app.style.display == 'none') return;
        var ch = parent.document.body.clientHeight, sh = parent.document.body.scrollHeight, st=parent.document.body.scrollTop;
        nw_shade.style.height = (sh > ch ? sh : ch) + 'px';
        nw_shade.style.width = parent.document.body.clientWidth + 'px';
        var nw_pos = [], nw_pw;
        if (nw_ptable) {
            nw_pos = getPosXY(nw_ptable);
            nw_pw = nw_ptable.offsetWidth || 760;
        } else {
            nw_pw = 760;
            nw_pos[0] = (parent.document.body.clientWidth-nw_pw)/2;
            nw_pos[1] = (ch-(nw_app.offsetHeight || 300))/2 + st;
        }
        if (navigator.product && navigator.product == 'Gecko') {
            nw_pw -= 40;
        }
        nw_app.style.left = nw_pos[0] + 'px';
        nw_app.style.top = nw_pos[1] + 'px';
        nw_app.style.width = nw_pw + 'px';
    }
    window.onresize = position;
    nw_shade.style.display = 'block';
    nw_app.style.display = 'block';
    position();
    if (nw_ptable)
        nw_ptable.style.visibility = 'hidden';
}
function hide_newwindiv() {
    if (nw_ptable)
    {
        nw_ptable.style.visibility = 'visible';
    }
    if (nw_app)
    {
        nw_app.style.display = 'none';
    }
    if (nw_shade)
    {
        nw_shade.style.display = 'none';
        parent.document.body.removeChild(nw_shade);
    }
}