var show_prompt_bg = true;
function Prompt(b,c,d,f){
    if(b && c){
        removePrompt();
        hideAllSelects();
        if(show_prompt_bg){
            var g = document.createElement("div");
            with(g.style){
                backgroundColor = "black";
                position = "absolute";
                zIndex = 99;
                filter = "alpha(opacity=50)";
                opacity = "0.5";
                height = getClientHeight() + "px";
                width = "100%";
                top = "0px";
                left = "0px"
            }
            g.id = "PROMPT_BG";
            document.body.appendChild(g)
        }
        var h = document.createElement("div");
        h.id = "PROMPT_DIV";
        with(h.style){
            zIndex = 100;
            backgroundColor = "#dfdfdf";
            position = "absolute";
            height = "160px";
            width = "348px";
            border = 'solid 3px #cfcfcf';
            left = "50%";
            marginLeft = "-175px";
            top = "50%";
            marginTop = "-75px"
        }
        var i = document.createElement("div");
        i.id = "PROMPT_IDIV";
        with(i.style){
            backgroundColor = "white";
            height = "158px";
            border = "solid 1px #000000"
        }
        if(c == "question"){
            if(f){
                i.innerHTML = "<table width='99%' style='height:75px;'><tr><td valign='middle' align='center'>" + b + "</td></tr></table><table width='100%' cellspacing='0' cellpadding='0' height='55px'><tr><td valign='middle' align='center'><input type='text' id='prompt_response' style='border:solid 1px gray; width:300px' value=\"" + f + "\"/><div style='text-align:center; padding-top:8px;'><input type='button' style='border:solid 1px gray; background-color:whitesmoke; width:50px;' value='Save' id='prompt_ok'/>&nbsp;&nbsp;<input type='button' id='prompt_cancel' style='width:50px; border:solid 1px gray; background-color:whitesmoke;' value='Cancel'/></div></td></tr></table>"
            }else{
                i.innerHTML = "<table width='99%' style='height:75px;'><tr><td valign='middle' align='center'>" + b + "</td></tr></table><table width='100%' cellspacing='0' cellpadding='0' height='55px'><tr><td valign='middle' align='center'><input type='text' id='prompt_response' style='border:solid 1px gray; width:300px' value=\"\"/><div style='text-align:center; padding-top:8px;'><input type='button' style='border:solid 1px gray; background-color:whitesmoke; width:50px;' value='Save' id='prompt_ok'/>&nbsp;&nbsp;<input type='button' id='prompt_cancel' style='width:50px; border:solid 1px gray; background-color:whitesmoke;' value='Cancel'/></div></td></tr></table>"
            }
        }else if(c == "confirm"){
            i.style.backgroundRepeat = "no-repeat";
            i.innerHTML = "<table width='99%' style='height:110px;'><tr><td valign='middle' align='left' id='PROMPT_TD' style='padding-left:50px'>" + b + "</td></tr></table><table width='100%' cellspacing='0' cellpadding='0' height='35px'><tr><td valign='middle' align='center'><input type='button' style='border:solid 1px gray; background-color:whitesmoke; width:80px;' value='Yes' id='prompt_yes'/>&nbsp;&nbsp;<input type='button' id='prompt_no' style='width:80px; border:solid 1px gray; background-color:whitesmoke;' value='No'/></td></tr></table>"
        }else if(c == "exclaim"){
            i.style.backgroundImage = "url('/lnp/javascript/images/exclaim.gif')";
            i.style.backgroundRepeat = "no-repeat";
            i.innerHTML = "<table width='99%' style='height:110px;'><tr><td valign='middle' align='center' style='padding-left:50px'>" + b + "</td></tr></table><table width='100%' cellspacing='0' cellpadding='0' height='35px'><tr><td valign='middle' align='center'><input type='button' style='border:solid 1px gray; background-color:whitesmoke; width:80px;' value='OK' id='prompt_ok'/></td></tr></table>"
        }else if(c == "div"){
            i.innerHTML = b
        }
        h.appendChild(i);
        document.body.appendChild(h);
        if(c == "question"){
            $("prompt_ok").onclick = function(){
                var a = $("prompt_response").value;
                a = a.replaceAll('"','').replaceAll("'","&apos;").trim();
                removePrompt();
                try{
                    eval(d + "(\"" + a + "\")")
                }catch(e){
                }
            };
            $("prompt_cancel").onclick = function(){
                removePrompt()
            };
            $("prompt_response").focus();
            $("prompt_response").onkeyup = function(e){
                try{
                    var a = e.keyCode?e.keyCode:e.which?e.which:e.charCode;
                    if(a == null)
                        return false;
                    if(a == 13){
                        $("prompt_ok").onclick()
                    }
                }catch(ex){
                }
                return false
            }
        }else if(c == "confirm"){
            $("prompt_yes").onclick = function(){
                removePrompt();
                try{
                    eval(d + "(true)")
                }catch(e){
                }
            };
            $("prompt_no").onclick = function(){
                removePrompt();
                try{
                    eval(d + "(false)")
                }catch(e){
                }
            };
            $("prompt_no").focus()
        }else if(c == "exclaim"){
            $("prompt_ok").onclick = function(){
                removePrompt();
                try{
                    eval(d + "(false)")
                }catch(e){
                }
            };
            $("prompt_ok").focus()
            
        }
    }
}
function removePrompt(){
    if(document.getElementById("PROMPT_DIV")){
        if(show_prompt_bg){
            document.body.removeChild(document.getElementById("PROMPT_BG"))
        }
        document.body.removeChild(document.getElementById("PROMPT_DIV"));
        showAllSelects()
    }
}
function f_clientHeight(){
    return f_filterResults(window.innerHeight?window.innerHeight:0,document.documentElement?document.documentElement.clientHeight:0,document.body?document.body.clientHeight:0)
}
function f_filterResults(a,b,c){
    var d = a?a:0;
    if(b && (!d || (d > b)))
        d = b;
    return c && (!d || (d > c))?c:d
}
function hideAllSelects(){
    var a = document.getElementsByTagName("select");
    var b = a.length;
    for( var i = 0; i < b; i = i + 1){
        if(a[i].style.visibility){
            a[i].oldvisibility = a[i].style.visibility
        }
        a[i].style.visibility = "hidden"
    }
}
function showAllSelects(){
    var a = document.getElementsByTagName("select");
    var b = a.length;
    for( var i = 0; i < b; i = i + 1){
        if(a[i].oldvisibility != "hidden"){
            a[i].style.visibility = ""
        }
    }
}