<%@  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"/>
<iman:eMFrameScripts/>

<html>
<head>
   <iman:stylesheet/>
   <script>
      function onExit()
      {
         var name = "<c:out value="${param.mved}"/>";
         var mvse = opener.mv<c:out value="${param.mved}"/>;

         var list = new Array();
         var opts = document.form.items.options;
         for(var i=0; i<opts.length; i++)
         {
            list[i] = opts[i].value;
         }

         var packStr = pack(list);
         opener.mvLoadFromPack(name, packStr);
         window.close();
      }

      function swapOptions(sel, i1, i2)
      {
         var o = sel.options;
         if(i1>=0 && i2>=0 && i1<o.length && i2<o.length)
         {
            var tmpVal = o[i1].value;
            var tmpText = o[i1].text;
            o[i1].value = o[i2].value;
            o[i1].text = o[i2].text;
            o[i2].value = tmpVal;
            o[i2].text = tmpText;
            o.selectedIndex = i1;
         }
      }

      function moveUp(sel)
      {
         swapOptions(sel, sel.selectedIndex-1, sel.selectedIndex);
      }

      function moveDown(sel)
      {
         swapOptions(sel, sel.selectedIndex+1, sel.selectedIndex);
      }
   </script>
</head>
<body onLoad="">
<form name="form">
   <iman:taskHeader titleKey="Mved.reorderItems"/><BR>

   <TABLE>
      <TR>
         <TD>
            <iman:unpack var="items" value="${param.pack}"/>
            <select name="items" size="10" style="width:<iman:string key="UI.textboxPixel"/>" >
               <c:forEach items="${items}" var="item">
                  <option value="<c:out value="${item}"/>"><c:out value="${item}"/></option>
               </c:forEach>
            </select><br/><br/>
         </TD>
         <TD>
            <A href="#" onClick="moveUp(document.form.items);"><IMG src="<c:out value="${ModulesPath}"/>/dev/images/up24.gif" border="0" alt="<iman:string key="TaskBuilder.MoveUp"/>" title="<iman:string key="TaskBuilder.MoveUp"/>"></A><BR>
            <A href="#" onClick="moveDown(document.form.items);"><IMG src="<c:out value="${ModulesPath}"/>/dev/images/down24.gif" border="0" alt="<iman:string key="TaskBuilder.MoveDown"/>" title="<iman:string key="TaskBuilder.MoveDown"/>"></A>
         </TD>
      </TR>
   </TABLE>

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