<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit2, com.novell.emframe.dev.eMFrameUtils" %>
<%   JSPConduit2 c = JSPConduit2.getJSPConduit(request); %>

<!-- BEGIN Pocket OSScripts.inc -->
<SCRIPT language="JavaScript" src="<%= c.getModulesUrl() %>/dev/javascripts/OSPocketScripts.js" ></script>

<script>
   function returnFromOS()
   {
      <% if (c.var("OS.ReturningToAnchor").equals("true")) { %>
      //1.  restore the document to the state it was in before calling the OS
      var docState = "<%= c.toScript(c.var("OS.AnchorDocState")) %>";
      if (docState != null && docState.length != 0)
      {
         //extract document state values and set them
         restoreDocStateInfo(docState);
      }
   
      //2.  now process the os results
      var osCallBack = "<%= c.toScript(c.var("OS.CallBack")) %>";
      var osControl  = "<%= c.toScript(c.var("OS.Control")) %>";
      var osResults  = "<%= c.toScript(c.var("OS.Results")) %>";
      if (osResults!=null && osResults.length>0)
      {
         // turn the one returned value into an array for compatibility with browser mode
         var osResultsArray = new Array(1);
         osResultsArray[0] = osResults;
   
         //process the os results that have been returned
         if (exists(osCallBack))
         {
            //let the callback routine process the os results
            var command = osCallBack+"('"+toScript(osControl)+"',osResultsArray)";
            eval( command );
         }
         else
         {
            //just store the search results in the specified control
            if (osControl != null)
            {
               setElementValue(osControl, osResults);
            }
         }
      }
   
      //3.  call task's post OS function
      if ("<%= c.var("OS.CustomProcessing") %>"=="true" && exists("postOS")) postOS(osControl);
      <% } %>
   }
</script>

<!-- clear local variables used in os.inc-->
<jsp:include page='<%= c.getPath("dev/ClearFlags_inc.jsp") %>' flush="true" />
<% c.set("OS.Results", ""); 
   c.set("OS.AnchorDocState", ""); 
   c.set("OS.URLUniqueID", ""); %>
<!-- END Pocket OSScripts.inc -->


