<%@ page import="com.novell.webaccess.common.JSPConduit"%>
<%@  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" %>
<%   JSPConduit jspc = JSPConduit.getJSPConduit(request);
   jspc.stringTable("DevResources");
   jspc.stringTable("BaseResources");
   jspc.stringTable("FwResources"); %>

<iman:stringtable bundle="DevResources"/>
<iman:stringtable bundle="FwResources"/>

<HTML>
<HEAD>
   <TITLE><iman:string key="ProductName"/></TITLE>
   <iman:stylesheet/>
   <iman:eMFrameScripts/>
   <iman:mvedScripts />

   <SCRIPT>
        function detectBrowser(){
            var iePos = navigator.appVersion.indexOf('MSIE');
                if (iePos != -1){
                    document.form.attrNoDisplay.attachEvent('ondblclick',showAttrDialog);
                    document.form.classNoDisplay.attachEvent('ondblclick',showClassDialog);
                }
                else{
                    var attrOpt = document.form.attrNoDisplay.options;
                    var classOpt = document.form.classNoDisplay.options;

                    sortAttrList(attrOpt);
                    sortClassList(classOpt);
                }
        }

        function sortAttrList(x)
        {
            sortedArray = new Array();

            for (var i=0; i<x.length; i++) {
                sortedArray[i] = new Array(x[i].text, x[i].value, false, false);
            }

            for (var i=0; i<x.length; i++) {
                x[i] = new Option(sortedArray[i][0], sortedArray[i][1], sortedArray[i][2], sortedArray[i][3]);
                x[i].addEventListener("dblclick",showAttrDialog, false);
                x[i].selected = sortedArray[i][3];
            }

            return;
        }

        function sortClassList(x)
        {
            sortedArray = new Array();

            for (var i=0; i<x.length; i++) {
                sortedArray[i] = new Array(x[i].text, x[i].value, false, false);
            }

            for (var i=0; i<x.length; i++) {
                x[i] = new Option(sortedArray[i][0], sortedArray[i][1], sortedArray[i][2], sortedArray[i][3]);
                x[i].addEventListener("dblclick",showClassDialog, false);
                x[i].selected = sortedArray[i][3];
            }

            return;
        }

      function showAttrDialog(event)
      {
         var select = document.form.attrNoDisplay;
         var index = select.selectedIndex;
         if(index!=-1)
         {
            var attrName = select.options[index].value;

            var url = "frameservice?taskId=<c:out value="${taskId}"/>&nextState=showEditDlg&add=true&attributeName="+attrName + "&type=attribute";
            window.open(url, "EnterValues", "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=540,height=625");
         }
      }

      function showClassDialog(event)
      {
         var select = document.form.classNoDisplay;
         var index = select.selectedIndex;
         if(index!=-1)
         {
            var attrName = select.options[index].value;

            var url = "frameservice?taskId=<c:out value="${taskId}"/>&nextState=showEditDlg&add=true&attributeName="+attrName + "&type=objectType";
            window.open(url, "EnterValues", "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=540,height=625");
         }
      }

      function onExit()
      {
         document.form.submit();
      }
   </SCRIPT>

</HEAD>
<BODY onLoad="detectBrowser()";>
<FORM name="form">
   <INPUT type="hidden" name="taskId" value="<c:out value="${taskId}"/>">
   <INPUT type="hidden" name="nextState" value="write">
   <INPUT type="hidden" name="classNames">
   <INPUT type="hidden" name="attributeNames">

   <% jspc.set("TaskHeader.title", jspc.string("CustomSchemaName.title"));
   jspc.set("TaskHeader.iconUrl", "dev/bullet_default_16.gif");
   jspc.set("TaskHeader.helpFile", "base/schemaobjectdisplaynames.html"); %>
   <jsp:include page='<%= jspc.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" />  <BR/>

   <DIV class="instructions"><iman:string key="CustomSchemaName.mainInstructions"/></DIV><BR>

<TABLE>
      <TR>
         <TD><iman:string key="CustomSchemaName.attributes"/></TD>
      </TR>
      <TR>
         <TD>
         	
            <SELECT name="attrNoDisplay" size="10" style="width:<iman:string key="UI.textboxPixel"/>">
               <c:forEach items="${attributes}" var="item" >
               		<%  
         				String id = "";
         			%>
               	  <c:forEach items="${customizedAttributes}" var="customizedItem" >
               	     <c:choose>
               	       <c:when test="${item==customizedItem}">                     
							<%
								id = "*";
							%>      		         	          
                       </c:when>    	       
               	     </c:choose>
               	  </c:forEach>
                  <OPTION value="<c:out value="${item}"/>"><%=id%><c:out value="${item}"/>
               </c:forEach>
            </SELECT>
         </TD>
         <TD valign="top">
            <iman:button key="Modify" onClick="showAttrDialog('attribute')"/>
         </TD>
      </TR>
   </TABLE><BR>

   <TABLE>
      <TR>
         <TD><iman:string key="CustomSchemaName.objectClasses"/></TD>
      </TR>
      <TR>
         <TD>
            <SELECT name="classNoDisplay" size="10" style="width:<iman:string key="UI.textboxPixel"/>">
               <c:forEach items="${classes}" var="item" >
                    <%  
         				String id = "";
         			%>
               	  <c:forEach items="${customizedClasses}" var="customizedItem" >
               	     <c:choose>
               	       <c:when test="${item==customizedItem}">                     
							<%
								id = "* ";
							%>      		         	          
                       </c:when>    	       
               	     </c:choose>
               	  </c:forEach>
                  <OPTION value="<c:out value="${item}"/>" ><%=id%><c:out value="${item}"/>
               </c:forEach>
            </SELECT>
         </TD>
         <TD valign="top">
            <iman:button key="Modify" onClick="showClassDialog('objectType')"/>
         </TD>
      </TR>
   </TABLE>


   <BR>
   <iman:bar/>
   <iman:button key="OK" onClick="onExit()"/>
   <iman:cancelBtn/>

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