<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" %>

<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<iman:stringtable bundle="FwResources"/>
<iman:stringtable bundle="DevResources"/>


<HTML>
<HEAD>
   <LINK rel="stylesheet" href="<c:out value="${ContextPath}" />/portal/modules/dev/css/hf_style.css">
   <SCRIPT src="<c:out value="${ContextPath}" />/portal/modules/fw/javascripts/Studio.js"></SCRIPT>
   <iman:eMFrameScripts/>
   <iman:mvedScripts/>
   <iman:osScripts/>

   <SCRIPT>

      function showCurrentOrder()
      {
         var url = "frameservice?taskId=dev.Empty&merge=fw.Studio_pageOrder";
         window.open(url, "PageOrderDlg", "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=600");
      }

	  function checkOrderValue(val)
	  {
		  <%-- Validate that the page order is a number between 0 and 1000 --%>
		  if(val.length>4)
          {
             alert("<iman:string key="Studio.pageOrderErrorMsg"/>");
             return false;
          }

          for(var i=0; i < val.length; i++)
          {
             if(val.charAt(i)<'0' || val.charAt(i)>'9')
             {
                alert("<iman:string key="Studio.pageOrderErrorMsg"/>");
                return false;
             }
          }
          
          if(val > 1000)
          {
              alert("<iman:string key="Studio.pageOrderErrorMsg"/>");
              return false;
          }
          return true;
	  }

      function onExit()
      {
         var openerForm = opener.document.pluginProperties;
         var form = document.form;
				 			
         openerForm.labelAboveControl.value = "" + document.form.labelAboveControl.checked;
         openerForm.displayName.value = document.form.displayName.value;

         <c:choose>
            <c:when test="${pluginType=='create'}">
               openerForm.modifyTask.value = document.form.modifyTask.value;
               openerForm.addToCreateObject.value = "" + document.form.addToCreateObject.checked;
               if(!checkOrderValue(document.form.taskOrder.value))
               {
                    return false;
               }
               openerForm.taskOrder.value = document.form.taskOrder.value;
            </c:when>
            <c:when test="${pluginType=='page'}">
               openerForm.objectTypeNameReg.value = mvGetValuesAsPack("objectTypeNameReg");

               if(!checkOrderValue(document.form.pageOrder.value))
               {
                    return false;
               }
               openerForm.pageOrder.value = document.form.pageOrder.value;

            </c:when>
            <c:otherwise>
            
			   if("true"==checkTcMode())
		 	   {
				  return;
			   }           
               openerForm.mooEnabled.value = "" + document.form.mooEnabled.checked;

               openerForm.objectTypeNameReg.value = pack([document.form.objectTypeNameReg.value]);

               openerForm.tcClassName.value = form.tcClassName.options[form.tcClassName.selectedIndex].value;
               
               openerForm.defaultTcMode.value = form.defaultTcMode.options[form.defaultTcMode.selectedIndex].value;
               
               openerForm.taskOrder.value = document.form.taskOrder.value;

               var index = document.form.tcClassName.selectedIndex;
               if(index==1)
               {
                  openerForm.tcStaticList.value = mvGetValuesAsPack("tcStaticList");
               }
               else if(index==2)
               {
                  openerForm.tcListObjectName.value = form.tcListObjectName.value;
               }
               if(!checkOrderValue(document.form.taskOrder.value))
               {
                    return false;
               }
               openerForm.taskOrder.value = document.form.taskOrder.value;
               
            </c:otherwise>
         </c:choose>




         window.close();
      }

      function updateTc()
      {
         var index = document.form.tcClassName.selectedIndex;

         if(index==0)
         {
            document.getElementById("tcDefaultListDiv").style.display = "block";
            document.getElementById("tcListObjectNameDiv").style.display = "none";
            document.getElementById("tcStaticListDiv").style.display = "none";
         }
         else if(index==1)
         {
            document.getElementById("tcDefaultListDiv").style.display = "none";
            document.getElementById("tcListObjectNameDiv").style.display = "none";
            document.getElementById("tcStaticListDiv").style.display = "block";
         }
         else if(index==2)
         {
            document.getElementById("tcDefaultListDiv").style.display = "none";
            document.getElementById("tcListObjectNameDiv").style.display = "block";
            document.getElementById("tcStaticListDiv").style.display = "none";
         }

      }

	  function checkTcMode()
	  {
	  	 if(document.form.defaultTcMode.selectedIndex==1 || document.form.defaultTcMode.selectedIndex==3)
	  	 {
	  	 	if(document.form.mooEnabled.checked != true)
	  	 	{
	  	 		alert("<iman:toScript><iman:string key="Studio.tcModeErrorMsg"/></iman:toScript>");
	  	 		return("true");
	  	 	}
	  	 	else
	  	 	{
	  	 		return("false");
	  	 	}
	  	 }
	  }
	  
      function doInit()
      {
      	 <c:if test="${pluginType=='task'}">
	         var className = "<c:out value="${tcClassName}"/>";
	
	         if(className=="com.novell.emframe.fw.StaticListTargetChooser")
	         {
	            document.form.tcClassName.selectedIndex = 1;
	         }
	         else if(className=="com.novell.emframe.fw.ListTargetChooser")
	         {
	            document.form.tcClassName.selectedIndex = 2;
	         }
	         else
	         {
	            document.form.tcClassName.selectedIndex = 0;
	            var mode = "<c:out value="${defaultTcMode}"/>";
	            if(mode=="simple")
	            {
					document.form.defaultTcMode.selectedIndex = 0;            
	            }
	            else if(mode=="advanced")
	            {
	            	document.form.defaultTcMode.selectedIndex = 1; 
	            }
	            else if(mode=="single")
	            {
	            	document.form.defaultTcMode.selectedIndex = 2; 
	            }
	            else if(mode=="multiple")
	            {
	            	document.form.defaultTcMode.selectedIndex = 3; 
	            }
	                      
	         }
	
	         updateTc();
		</c:if>
      }
   </SCRIPT>
</HEAD>

<BODY onLoad="doInit()">
<FORM name="form">

	<c:choose>
      <c:when test="${pluginType=='create'}">
	      <iman:taskHeader titleKey="Studio.advancedProperties" titleBundle="FwResources" helpFile="fw/advancedRBSCreate.html" /><BR>
	  </c:when>
      <c:when test="${param.pluginType=='task'}">
          <iman:taskHeader titleKey="Studio.advancedProperties" titleBundle="FwResources" helpFile="fw/advancedRBS.html" /><BR>
      </c:when>
      <c:when test="${param.pluginType=='page'}">
    	  <iman:taskHeader titleKey="Studio.advancedProperties" titleBundle="FwResources" helpFile="fw/advancedRBSPage.html" /><BR>
      </c:when>
      <c:otherwise>
      </c:otherwise>
   </c:choose>      
            
   <TABLE>

      <TR><TD><iman:nobr><iman:string key="Studio.displayName"/></iman:nobr></TD><TD width="100%"><INPUT type="text" name="displayName" value="<c:out value="${param.displayName}"/>" style="width:<iman:string key="UI.textboxPixel"/>"></TD></TR>
      <TR><TD colspan="2"><INPUT type="checkbox" name="labelAboveControl" value="true" <c:if test="${param.labelAboveControl=='true'}">checked</c:if>>&nbsp;<iman:string key="TaskBuilder.LabelsAboveControls"/></TD></TR>



      <iman:unpack var="objectTypeNameRegArray" value="${param.objectTypeNameReg}"/>
      <c:choose>
         <c:when test="${pluginType=='create'}">
            <TR><TD colspan="2">
               <INPUT type="checkbox" name="addToCreateObject" value="true" <c:if test="${param.addToCreateObject=='true'}">checked</c:if>>&nbsp;<iman:string key="Studio.addToCreateObjectTask"/>
            </TD></TR>

            <c:set var="modifyTask" value="${param.modifyTask}"/>
            <c:if test="${empty modifyTask}">
               <c:set var="modifyTask" value="base.ModifyObject"/>
            </c:if>

            <TR>
               <TD nowrap><iman:string key="Studio.modifyTaskToLaunch"/></TD>
               <TD><INPUT type="text" name="modifyTask" value="<c:out value="${modifyTask}"/>"></TD>
            </TR>
             <TR>
               <TD nowrap><iman:string key="Studio.pageOrderPrompt"/></TD>
               <TD><INPUT type="text" name="taskOrder" value="<c:out value="${taskOrder}"/>"></TD>
            </TR>
         </c:when>
         <c:when test="${param.pluginType=='task'}">
            <TR><TD colspan="2"><INPUT type="checkbox" name="mooEnabled" value="true" <c:if test="${param.mooEnabled=='true'}">checked</c:if>>&nbsp;<iman:string key="TaskBuilder.MultipleObjectEnabled"/></TD></TR>
            <TR>
               <TD><iman:string key="Studio.objectType"/></TD>
               <TD>
                  <INPUT type="text" name="objectTypeNameReg" id="objectTypeNameReg" value="<c:out value="${objectTypeNameRegArray[0]}"/>" style="width:<iman:string key="UI.textboxPixel"/>">
                  <iman:objectClassBroswer fieldId="objectTypeNameReg"/>
               </TD>
            </TR>

            <TR>
               <TD nowrap valign="top"><iman:string key="Studio.targetChooser"/></TD>
               <TD>
                  <select name="tcClassName" onChange="updateTc()" style="width:<iman:string key="UI.textboxPixel"/>">
                     <option value="none"><iman:string key="Studio.defaultTc"/></option>
                     <option value="com.novell.emframe.fw.StaticListTargetChooser"><iman:string key="Studio.staticListTc"/></option>
                     <option value="com.novell.emframe.fw.ListTargetChooser"><iman:string key="Studio.listTc"/></option>
                  </select>
                  
                  <div id="tcDefaultListDiv" style="display:block">
                     <table cellpadding="0" cellspacing="0">
                        <tr>
                           <td><iman:string key="Studio.defaultTcMode"/></td>
                           <td>
                           	<select name="defaultTcMode" onChange="checkTcMode()" value="<c:out value="${defaultTcMode}"/>">
        	                   	<option value="simple"><iman:string key="Studio.TC.simple"/></option>
    	                       	<option value="advanced"><iman:string key="Studio.TC.advanced"/></option>
	                           	<option value="single"><iman:string key="Studio.TC.single"/></option>
                           		<option value="multiple"><iman:string key="Studio.TC.multiple"/></option>
                           </td>
                        </tr>
                     </table>
                  </div>

                  <div id="tcStaticListDiv" style="display:none">
                     <table cellpadding="0" cellspacing="0">
                        <tr>
                           <td><iman:string key="Studio.listMembers"/></td><td><iman:mved name="tcStaticList" items="${tcStaticList}" objectTypeName="*"/></td>
                        </tr>
                     </table>
                  </div>

                  <div id="tcListObjectNameDiv" style="display:none">
                     <table cellpadding="0" cellspacing="0">
                        <tr>
                           <td><iman:string key="Studio.listObject"/></td><td><input type="text" name="tcListObjectName" value="<c:out value="${tcListObjectName}"/>" style="width:<iman:string key="UI.textboxPixel"/>"/> <iman:os typeFilter="List,Group" control="tcListObjectName" /></td>
                        </tr>
                     </table>
                  </div>

               </TD>
            </TR>
             <TR>
               <TD nowrap><iman:string key="Studio.pageOrderPrompt"/></TD>
               <TD><INPUT type="text" name="taskOrder" value="<c:out value="${taskOrder}"/>"></TD>
            </TR>

         </c:when>
         <c:when test="${param.pluginType=='page'}">
            <TR>
               <TD><iman:string key="Studio.objectType"/></TD>
               <TD>
                  <TABLE cellpadding="0" cellspacing="0">
                     <TR>
                        <TD><iman:mved name="objectTypeNameReg" items="${objectTypeNameRegArray}" /></TD>
                        <TD><iman:objectClassBroswer mvedName="objectTypeNameReg" /></TD>
                     </TR>
                  </TABLE>
               </TD>
            </TR>
            <TR>
               <TD nowrap><iman:string key="Studio.pageOrderPrompt"/></TD>
               <TD><INPUT type="text" name="pageOrder" value="<c:out value="${pageOrder}"/>">&nbsp;<a href="Javascript: showCurrentOrder()"><iman:string key="Studio.seeCurrentOrder"/></a></TD>
            </TR>
         </c:when>
         <c:otherwise>
               <INPUT type="hidden" name="objectTypeNameReg" value="<c:out value="${objectTypeNameRegArray[0]}"/>">
         </c:otherwise>
      </c:choose>

   </TABLE>


   <BR>
   <iman:bar/>
   <iman:button key="OK" onClick="onExit();"/>
   <iman:button key="Cancel" onClick="window.close()"/>

   <iman:dump toResponse="false"/> 

</FORM>
</BODY>
</HTML>
