<%@  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"); %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>

<HTML>
<HEAD>
   <TITLE><%= c.string("ProductName") %></TITLE>
   <iman:eMFrameScripts />
   <iman:include page="dev/HelpScripts_inc.jsp" /> 

   <SCRIPT>
      var oldButtons = null;

      window.nextButton   = 1;
      window.backButton   = 2;
      window.cancelButton = 4;
      window.finishButton = 8;
      window.closeButton = 16;

      window.nextDisabledButton   = 32;
      window.backDisabledButton   = 64;
      window.cancelDisabledButton = 128;
      window.finishDisabledButton = 256;
      window.closeDisabledButton = 512;

      function setHeader(title, subtitle, helpfile)
      {
         <%/*------------------------------------------------------- */
           /*-- Timing issue: make sure the wizard footer frame   -- */
           /*-- is loaded before we try to set header text        -- */
           /*------------------------------------------------------- */%>
         if(!partWizardHeader.document.getElementById("title"))
         {
            var str = "setHeader(\"" + title + "\", \"" + subtitle + "\", \"" + helpfile + "\");";
            //setTimeout(setHeader, 200, title, subtitle, helpfile);
            setTimeout(str, 200);
            return;
         }

         window.helpfile = helpfile;
         partWizardHeader.document.getElementById("title").innerHTML = title;
         partWizardHeader.document.getElementById("subtitle").innerHTML = subtitle;
         partWizardHeader.document.getElementById("helpimage").style.display = (helpfile?"inline":"none");
      }

      function setFooterButtons(buttons)
      {
         <%/*------------------------------------------------------- */
           /*-- Timing issue: make sure the wizard footer frame   -- */
           /*-- is loaded before we try to enable/disable buttons -- */
           /*------------------------------------------------------- */%>
         if(!partWizardFooter.document.getElementById("backButton"))
         {
            setTimeout("setFooterButtons(" + buttons + ")", 200);
            return;
         }

         if(oldButtons!=buttons)
         {
            setButton("backButton", buttons&backButton );
            setButton("nextButton", buttons&nextButton );
            setButton("cancelButton", buttons&cancelButton );
            setButton("finishButton", buttons&finishButton );
            setButton("closeButton", buttons&closeButton );

            setButton("backDisabledButton", buttons&backDisabledButton );
            setButton("nextDisabledButton", buttons&nextDisabledButton );
            setButton("cancelDisabledButton", buttons&cancelDisabledButton );
            setButton("finishDisabledButton", buttons&finishDisabledButton );
            setButton("closeDisabledButton", buttons&closeDisabledButton );

            oldButtons = buttons;
         }
      }

      function setButton(buttonName,bDisplay)
      {
         wizardFooter.document.getElementById(buttonName).style.display=(bDisplay>0?"inline":"none");
      }

      function disableButtons()
      {
         setFooterButtons( (oldButtons << 5) | (oldButtons & 1008) );
      }

      function doAction(strAction)
      {
		   var partWindow = partWizardBody;
		   var partForm = partWizardBody.document.forms[0];
		   var part = "<c:out value='${currentPart}' />";
		   
		      // is page loaded
		   var pageLoaded = (typeof partForm != "undefined");
		   if(pageLoaded && MS55 && wizardBody.document.readyState!="complete")
		   {
		      pageLoaded = false;
		   }
		
//		   if(!pageLoaded || !pageForm.activePage)
//		   {
//		      if(strAction=="show")
//		      {
//		         var doc = wizardBody.document;
//		         var tag = " <INPUT type=hidden name=";
//		         doc.open();
//		         doc.writeln('<HTML><BODY><FORM action="webacc">');
//		         doc.writeln(tag + 'taskId value="'+vars_taskId+'">');
//		         doc.writeln(tag + 'nextPage value="'+part+'">');
//		         doc.writeln(tag + 'nextState value="show">');
//		         doc.writeln('</FORM></BODY></HTML>');
//		         doc.close();
//		         doc.forms[0].submit();
//		      }
//		
//		      // apply ignored if page not loaded
//		      return;
//		   }
		   
		   
         if(typeof partWindow.handleAction == "function" && wizardBody.handleAction(strAction))
         {
            return;
         }


         if(strAction == "nextButton" || strAction == "finishButton")
         {
            if(typeof partWindow.isPageValid == "function" && !wizardBody.isPageValid())
            {
               return;
            }
            
  			partForm.nextState.value=strAction;          

            disableButtons();
            partForm.submit();
         }
         else if(strAction == "backButton")
         {
            disableButtons();
            window.wizardBody.history.go(-1);  <%/* wierd hack;  go back one on NS and to on IE" go(MS4?-2:-1) */%>
         }
         else if(strAction == "cancelButton" || strAction == "closeButton")
         {
            window.location = "webacc?NPService=fw.LaunchService&NPAction=Return&returnID=<%= c.urlEncode(c.var("taskId")) %>";
         }
      }

      function showHelpWindow()
      {
         launchHelp(window.helpfile);
      }
   </SCRIPT>

</HEAD>

<FRAMESET ROWS="50px,100%,42px" frameborder=0 ID="partWizardFrameset" >
    <FRAME name="wizardHeader" ID="partWizardHeader" SCROLLING=auto src="webacc?taskId="+fw_taskId+"&nextState=header&merge=fw.ParticipantWizardFrameHeader" marginheight=3 marginwidth=6>
    <FRAME name="wizardBody"   ID="partWizardBody" SCROLLING=auto src="webacc?User.context=<%= c.var("User.context") %>&taskId="+fw_taskId+"&nextState=<c:out value='${wizardBodyNextState}' />" marginheight=0 marginwidth=6>
    <FRAME name="wizardFooter" ID="partWizardFooter" SCROLLING=auto src="webacc?taskId="+fw_taskId+"&nextState=footer&merge=dev.WizardFrameFooter" marginheight=0 marginwidth=6>
</FRAMESET>
</HTML>
