/* ------------------------------------------ * Script Crated By Lorenzo Zanivan | Oxalis * ------------------------------------------ */var DIALOG_OK = 1;var DIALOG_OK_CANCEL = 2;var DIALOG_OK_CANCEL_CHECK = 3;var buttonResult;function openDialog(question, type, okFunction, name, style){    var textLayer = document.getElementById(name);    if (textLayer == undefined)        textLayer = createTextLayer(name);    else        textLayer.innerHTML = "";    //TODO Show button and text    var selectedStyle = (style != "" ? "class=\"" + style + "\"" : "");    var text = "";    text += "<table " + selectedStyle + ">";    text += "<tr>";    text += "<td>" + question + "</td>";    text += "</tr>";    text += "<tr>";    if (type == DIALOG_OK)    {        text += "<td style=\"padding-top: 7px;\">";        text += "<input type=\"button\" value=\"OK\" ";        text += "onclick=\"buttonResult = 'OK'; document.getElementById('" + name + "').style.display = 'none'; setTimeout('" + okFunction + "', '0');\" />";        text += "</td>";    }    else if (type == DIALOG_OK_CANCEL)     {        text += "<td style=\"padding-top: 7px;\">";        text += "<input type=\"button\" value=\"OK\" ";        text += "onclick=\"buttonResult = 'OK'; document.getElementById('" + name + "').style.display = 'none'; setTimeout('" + okFunction + "', '0');\" /> ";        text += "<input type=\"button\" value=\"Annulla\" ";        text += "onclick=\"buttonResult = 'CANCEL'; document.getElementById('" + name + "').style.display = 'none';\" />";        text += "</td>";    }    else if (type == DIALOG_OK_CANCEL_CHECK)     {        var checkId = "cbo_" + Math.random()*500;        text += "<td style=\"padding-top: 7px;\">";        text += "<input type=\"checkbox\" id=\"" + checkId + "\" name=\"" + checkId + "\" value=\"OK\" />Accetto";        text += "</td></tr><tr>";        text += "<td style=\"padding-top: 7px;\">"        text += "<input type=\"button\" value=\"OK\" ";        text += "onclick=\"if (!document.getElementById('" + checkId + "').checked) { alert('E\\' necessario accettare per continuare'); return; } buttonResult = 'OK'; document.getElementById('" + name + "').style.display = 'none'; setTimeout('" + okFunction + "', '0');\" /> ";        text += "<input type=\"button\" value=\"Annulla\" ";        text += "onclick=\"buttonResult = 'CANCEL'; document.getElementById('" + name + "').style.display = 'none';\" />";        text += "</td>";    }    text += "</tr>";		      text += "</table>";    //Show Alert    textLayer.innerHTML = text;    textLayer.style.display = "block";    var winW = 0;    var winH = 0;    if (navigator.appName=="Netscape") {        winW = window.innerWidth;        winH = window.innerHeight;    }    else if (navigator.appName.indexOf("Microsoft")!=-1) {        winW = document.body.offsetWidth;        winH = document.body.offsetHeight;    }    var leftPos = (winW - textLayer.offsetWidth)/2;    var rightPos = (winH - textLayer.offsetHeight)/2;        textLayer.style.left = leftPos + "px";    textLayer.style.top = rightPos + "px";		}function resultDialog(){    return buttonResult;}function createTextLayer(name){    var text = "";    text += "<div id=\"" + name + "\" name=\"" + name + "\" style=\"position: absolute; display: none;\">";    text += "</div>";    document.body.innerHTML += text;    return document.getElementById(name); }
