<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="enrgise" %>
<%@ page import="wenrgise.common.utility.EnrgiseConstants" %>

<html:html locale="true">
<head>
  <html:base />
  <LINK href="../includes/ENRGISE.css" rel=stylesheet> <title><bean:message key="wenrgise.common.confirm" /></title>
</head>
<enrgise:errors />

<body onload="checkOnLoad();" scroll="no" class="confirmDialog" >
<html:form  name="GenConfirmForm"  action="/ConfirmAction"  type="wenrgise.common.webtier.form.ConfirmForm" method="post">
<!-- Hidden Fields -->     

<html:hidden property="confirmKey" />
<html:hidden property="submitFirst" /> 

<html:hidden property="trueKey" />
<html:hidden property="falseKey" />
<html:hidden property="dismissKey" />



<br>
<table>
  <tr >
    <logic:notEmpty property="confirmKey" name="GenConfirmForm" >
      <bean:define id="oConfirmKey" property="confirmKey" name="GenConfirmForm" />
      <td width="15%" class="confirmDialog" ><bean:message  key="<%=oConfirmKey%>" /></td>
    </logic:notEmpty>
    <logic:empty property="confirmKey" name="GenConfirmForm" >
      <td width="15%" class="confirmDialog" ><bean:message  key="wenrgise.common.confirmDialog.confirmKeyError" /></td>
    </logic:empty>
  </tr>
</table>
<br>
<br>
 
<bean:define id="trueKey" property="trueKey" name="GenConfirmForm" />
<bean:define id="falseKey" property="falseKey" name="GenConfirmForm" />
<bean:define id="dismissKey" property="dismissKey" name="GenConfirmForm" />

<table cellpadding="0" cellspacing="0"  >
    <logic:equal property="falseKey" name="GenConfirmForm" value="wenrgise.common.blank" >
    <tr>
      <td width="100%" align="center"><button name="butOK" onclick="SaveExit(0);" ><bean:message key="<%=trueKey%>" /></button></td>
    </tr>
    </logic:equal>
    <logic:equal property="dismissKey" name="GenConfirmForm" value="wenrgise.common.blank" >
    <tr>
      <td width="45%" align="right"><button name="butOK" onclick="SaveExit(0);" ><bean:message key="<%=trueKey%>" /></button></td>
      <td width="10%">&nbsp;</td>
      <td width="45%" align="left"><button name="butCancel" onclick="SaveExit(1);" ><bean:message key="<%=falseKey%>" /></button></td>
    </tr>
    </logic:equal>
    <logic:notEqual property="dismissKey" name="GenConfirmForm" value="wenrgise.common.blank" >
    <tr>
      <td width="30%" align="right"><button name="butOK" onclick="SaveExit(0);" ><bean:message key="<%=trueKey%>" /></button></td>
      <td width="30%" align="center"><button name="butCancel" onclick="SaveExit(1);" ><bean:message key="<%=falseKey%>" /></button></td>
      <td width="30%" align="left"><button name="butDismiss" onclick="SaveExit(2);" ><bean:message key="<%=dismissKey%>" /></button></td>
    </tr>
    </logic:notEqual>
</table>
</logic:notEmpty>
</html:form>
</body>
</html:html>


<script language="javascript" >
var iOpenerFieldCount;

function setButtonKeys(fieldString)
{
  aryKeys = new Array();
  aryKeys = fieldString.split(",");
  iOpenerFieldCount=aryKeys.length;

  
  
  if(iOpenerFieldCount==0)
  {
    document.forms[0].trueKey.value = "wenrgise.common.ok" ;
    document.forms[0].falseKey.value = "wenrgise.common.cancel" ;
  }
  if(iOpenerFieldCount==1)
  {
    document.forms[0].trueKey.value = aryKeys[0];
    document.forms[0].falseKey.value = "wenrgise.common.cancel" ;
  }
  if(iOpenerFieldCount==2)
  {
    document.forms[0].trueKey.value = aryKeys[0];
    document.forms[0].falseKey.value = aryKeys[1];
  }
  if(iOpenerFieldCount==3)
  {
    document.forms[0].trueKey.value = aryKeys[0];
    document.forms[0].falseKey.value = aryKeys[1];
    document.forms[0].dismissKey.value = aryKeys[2];
  }

}


function checkOnLoad(){
  if(document.forms[0].submitFirst.value!="false"){
    //Set the Buttons  
   //----------------
   if(opener.document.getElementsByName("buttonKeys")[0])
     setButtonKeys(opener.document.getElementsByName("buttonKeys")[0].value);
   
   //Set the ConfirmKey  
   //------------------
   if(opener.document.getElementsByName("confirmKey")[0])
     document.forms[0].confirmKey.value=opener.document.getElementsByName("confirmKey")[0].value;
   else
     alert('confirmKey not defined as hidden field in jsp page'); 
     
   document.forms[0].submit();
   
  }  
}

function SaveExit(response)
{ 
         if(opener.doPostConfirm){
              opener.doPostConfirm(document.forms[0].confirmKey.value,response);
          }
          else{
              alert('doPostConfirm() not set in form');    
          }
  
    self.close();
}


</script> 

