<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit"%>

<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>

<iman:stringtable bundle="FwResources"/>
<iman:stringtable bundle="DevResources"/>
<%JSPConduit c = JSPConduit.getJSPConduit(request);
   c.set("TaskHeader.title", c.string("OS.Simple.BrowseDir")); 
   c.set("TaskHeader.bgcolor", "#E0E1DF");
%>

<HTML>
<HEAD>
   <LINK rel="stylesheet" href="<c:out value="${ContextPath}" />/portal/modules/fw/css/osStyles.css">
   <SCRIPT src="<c:out value="${ContextPath}" />/portal/modules/fw/javascripts/Studio.js"></SCRIPT>
   <iman:eMFrameScripts/>
   <iman:mvedScripts/>
   <iman:osScripts/>
   <jsp:include page='<%= c.getPath("dev/XmlScripts_inc.jsp") %>' flush="true" />
   
   <SCRIPT>
   function onExit()
   {
      if (document.form.query.selectedIndex == -1)
	   {
	      alert('<iman:string key="TC.selectQuery"/>');
	      return;
	   }
      else
	   {
	     var cnt=0;
	     for(var i=0;i<document.form.query.length;i++)
	     {
	        if(document.form.query.options[i].selected)
	        	cnt++;
	     }
	     
	     if(cnt > 1)
	     {
	        alert('<iman:string key="TC.SelectSingleOnLoad"/>');
	        return;
	     }
	     
         var query = document.form.query.options[document.form.query.selectedIndex].value;
      	var queryObject = buildQueryObject(query);
      	if (exists(opener.<%=c.var("loadFunctionName")%>))
         {
      	   eval(opener.<%=c.var("loadFunctionName")%>(queryObject));
      	}
         else if (fw_isDebugEnabled)
         {
      	 	alert("Developer Error.  Load Query function '<%=c.var("loadFunctionName")%>'does not exists.");
      	}
      	
      }
      window.close();
   }

   function doDelete()
   {
      if (document.form.query.selectedIndex == -1)
      {
         alert("<iman:string key="TC.selectQuery"/>");
      }
      else
      {
         var selectedIndices = new Array();
         var count = 0;
         for (i=0; i<document.form.query.options.length; i++) 
         {
            if (document.form.query.options[i].selected) 
            {
               selectedIndices[count] = i;
               count++;
            }
         }
      
         document.form.deleteIndex.value = pack(selectedIndices);
         document.form.nextState.value = "delete";
         document.form.submit();
      }
   }
   </SCRIPT>
</HEAD>

<BODY bgcolor="#E0E1DF">
<FORM name="form" method="post" action="webacc">

   <INPUT type="hidden" name="taskId" value="<c:out value="${taskId}"/>">
   <INPUT type="hidden" name="nextState" value="save">
   <INPUT type="hidden" name="deleteIndex" value="">


   <FONT face="Helvetica,Arial" ><b><iman:string key="TC.LoadQueryTitle"/></b></FONT><br/><br/>
   <FONT face="Helvetica,Arial" size=-1><b><iman:string key="TC.SavedQueries"/></b></FONT><br/>
   <SELECT name="query" size="10" style="width:<iman:string key="UI.textboxPixel"/>" multiple>
      <c:forEach items="${queries}" var="item">
         <OPTION value="<c:out value="${item.query}"/>" ><c:out value="${item.name}"/>
      </c:forEach>
   </SELECT>


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

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