<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit, com.novell.emframe.dev.eMFrameUtils" %>
<%   JSPConduit c = JSPConduit.getJSPConduit(request); 
   c.stringTable("DevResources"); 
   c.stringTable("FwResources"); %>
<HTML>
<HEAD>
<TITLE><%= c.string("InstallPackage.Title") %></TITLE>
<LINK   href="<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>"
        rel="styleSheet"
        type="text/css">
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
<jsp:include page='<%= c.getPath("dev/OSScripts_inc.jsp") %>' flush="true" />
<jsp:include page='<%= c.getPath("dev/MoveListItems_inc.jsp") %>' flush="true" />
<script language="JavaScript">


   /*******************
    * FUNCTION HEADER *
    *******************/
    function onPageLoad()
    {
        var form = document.InstallPackageForm;
        var list = form.List;

        if(list.selectedIndex == -1)
        {
            sortLists(list);
            if( list.length > 0 )
            {
                list.focus();
                list.options[0].selected=true;
            }
        }
        else
        {
            if( list.length > 0 )
            {
	            var selectedItems = new Array();
                var count = 0;
                for(i = 0; i < list.length; i++)
                {
                    if(list.options[i].selected)
                    {
                        selectedItems[count] = i;
                        count++;
                    }
                }
                
                sortLists(list);
                
                for(j=0; j < selectedItems.length; j++)
                {
                    list.options[selectedItems[j]].selected=true;
                }
            }
            
            form.InstallContext_Name.focus();
        }
    }


   /*******************
    * FUNCTION HEADER *
    *******************/
    function onPageClick()
    {
        if(onPageSubmit() == false)
        {
            return false;
        }

        document.InstallPackageForm.submit();
    }

   /*******************
    * FUNCTION HEADER *
    *******************/
    function onPageSubmit()
    {
        if(checkRequiredFields() == false)
        {
            return false;
        }

	    var selectedItems = new Array();
        var form = document.InstallPackageForm;
        var list = form.List;

        var count = 0;
        for(i = 0; i < list.length; i++)
        {
            if(list.options[i].selected)
            {
                selectedItems[count] = list.options[i].value;
                count++;
            }
        }

        form.elements["Selected_Item"].value=pack(selectedItems);
    }


   /*******************
    * FUNCTION HEADER *
    *******************/
    function checkRequiredFields()
    {
        var form = document.InstallPackageForm;
        var list = form.List;

        if(list.selectedIndex == -1)
        {
            alert("<%= c.string("RBSCollectionName.NoSelection") %>");
            return false;
        }

        var contextName = form.InstallContext_Name.value;
        if ((contextName == null) || (contextName.length == 0))
        {
            alert("<%= c.string("InstallPackage.ContainerField") %>");
            return false;
        }
        return true;
    }


</script>
</HEAD>

<BODY   TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF"
        onLoad="onPageLoad();returnFromOS()">

<form   name="InstallPackageForm"
        method=post
        action="webacc"
        onSubmit="return(onPageSubmit())">

    <input   type=hidden
            name="taskId"
            value="<%= c.var("taskId") %>">

    <input   type=hidden
            name="merge"
            value="dev.GenConf">

    <input   type=hidden
            name="error"
            value="dev.GenErr">

    <input   type=hidden
            name="User.context"
            value="<%= c.var("User.context") %>">

    <input   type=hidden
            name="nextState"
            value="doInstallPackage">

    <input  type=hidden
            name="Selected_Item"
            value="">

   <% c.set("TaskHeader.title", c.toHTML(c.string("InstallPackage.TaskHeaderTitle"))); 
      c.set("TaskHeader.helpFile", "base/installplugin.html"); %>
   <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" /><BR>

    <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <TD class="mediumtext">
             <%= c.string("InstallPackage.SelectPackage") %><br>
                <select size="10" name="List" multiple style="WIDTH: 380px">
                    <% c.set("i", "0"); 
                       while (c.lt(c.var("i"), c.var("FileList.Count"))) { %>
                        <OPTION value="<%= c.toHTML(c.var("FileList.Element."+c.var("i"))) %>"><%= c.toHTML(c.var("FileList.Element."+c.var("i"))) %>
                        <% c.inc("i"); 
                       } %>
                </select>
            </td>
        </tr>
        <TR>
            <TD class="mediumtext">
                &nbsp;
            </td>
        </TR>
        <tr>
            <td class="mediumtext">
                <%= c.string("InstallPackage.rbsContainer") %><br>
                <input  type="text"
                        name="InstallContext_Name"
                        value="<%= c.toHTML(c.var("SearchResults")) %>"
                        size="60">
	            <% c.set("OS.TypeFilter", "rbsCollection2");
	               c.set("OS.Control", "InstallContext_Name"); 
		           c.set("OS.Mode", "Search"); 
                 c.set("OS.History", "true"); %>
	            <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
	        </td>
        </tr>
        <TR>
            <TD class="mediumtext">
                &nbsp;
            </td>
        </TR>
    </table>
   <jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" />
        <a href="#" onClick="javascript:onPageClick();return false">
        <IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.OK.image") %>" alt="<%= c.string("Button.OK.alt") %>" alt="<%= c.string("Button.OK.alt") %>" border=0></a>
        <jsp:include page='<%= c.getPath("dev/Cancel_inc.jsp") %>' flush="true" />
</form>
<jsp:include page='<%= c.getPath("dev/OSFooter_inc.jsp") %>' flush="true" />
</BODY></HTML>
