top.importt("js.alertbox.AlertBox");

top.ConfirmBox = function ConfirmBox() {

  this.id = "confirm";
  this.buttonPath  = "";
  this.cssArqName  = "DefaultGreen";
  this.txtRet = null;
  this.fn = function(){};

  this.alertBoxHTML = "";
  this.alertBoxHTML += "<table cellpadding='0' cellspacing='0' class='table_alertBox'>";
  this.alertBoxHTML += "<tr>";
  this.alertBoxHTML += "<td id='alertBoxTitle" + this.id + "' class='td_alertBoxTitle' onmousedown='top.activateConfirmBox(event);'>&nbsp;</td>";
  this.alertBoxHTML += "</tr>";
  this.alertBoxHTML += "<tr>";
  this.alertBoxHTML += "<td class='td_alertBox'>";
  this.alertBoxHTML += "<table cellpadding='0' cellspacing='0' class='table_alertBoxMsg'>";
  this.alertBoxHTML += "<tr>";
  this.alertBoxHTML += "<td class='td_alertBoxMsg'>";
  this.alertBoxHTML += "<div id='alertBoxMsg" + this.id + "' class='div_alertBoxMsg'>&nbsp;</div>";
  this.alertBoxHTML += "</td>";
  this.alertBoxHTML += "</tr>";
  this.alertBoxHTML += "<tr>";
  this.alertBoxHTML += "<td class='td_alertBoxButton'>";
  this.alertBoxHTML += "<input id='alertBoxButtonOk' type='button' name='alertBoxButtonOk' value='&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;' onclick='top.closeConfirmBox(true);' class='input_alertBoxButton'>";
  this.alertBoxHTML += "&nbsp;&nbsp;&nbsp;&nbsp;";
  this.alertBoxHTML += "<input id='alertBoxButton' type='button' name='alertBoxButton' value='&nbsp;&nbsp;&nbsp;CANCEL&nbsp;&nbsp;&nbsp;' onclick='top.closeConfirmBox(false);' class='input_alertBoxButton'>";
  this.alertBoxHTML += "</td>";
  this.alertBoxHTML += "</tr>";
  this.alertBoxHTML += "</table>";
  this.alertBoxHTML += "</td>";
  this.alertBoxHTML += "</tr>";
  this.alertBoxHTML += "</table>";

  this.confirm = function(msg, title, fn) {
    if(!title) return;
    if(!fn) {
      this.fn = title;
      this.alert(msg);
    } else {
      this.fn = fn;
      this.alert(msg, title);
    }
  }

  this.closeConfirm = function(resp) {
    this.closeAlert();
    this.fn(resp);
  }
}
top.ConfirmBox.prototype.extendss("AlertBox");
top.ConfirmBox.instance = null;
top.ConfirmBox.getInstance = function() {
  if(this.instance == null) {
    this.instance = new top.ConfirmBox();
  }
  return this.instance;
}

top.confirmbox = function confirmbox(msg, title, retVar, fn) {
  top.ConfirmBox.getInstance().confirm(msg, title, retVar, fn);
}
top.activateConfirmBox = function (e) {
  top.ConfirmBox.getInstance().activateAlertBox(e);
}
top.closeConfirmBox = function(resp) {
  top.ConfirmBox.getInstance().closeConfirm(resp);
}
