<page
      xmlns="http://xmlns.oracle.com/uix/controller"
      xmlns:ctrl="http://xmlns.oracle.com/uix/controller"
      xmlns:baja="http://bali.us.oracle.com/cabo/baja"
      xmlns:marlin="http://bali.us.oracle.com/cabo/marlin"
      xmlns:html="http://www.w3.org/TR/REC-html40"
      xmlns:data="http://bali.us.oracle.com/cabo/marlin"
      >

  <baja:head  xmlns="http://bali.us.oracle.com/cabo/marlin"
              xmlns:uix="http://bali.us.oracle.com/cabo/marlin"
              xmlns:html="http://www.w3.org/TR/REC-html40">
    <dataScope>
      <contents>
        <html:title>
          <text text="Oracle Enterprise Manager  - Please wait - page loading..."/>
        </html:title>
        <html:noScript>
        "This page uses JavaScript to perform the list of values lookup. Your browser either does not support JavaScript, or it is disabled.  Please enable JavaScript, or upgrade your browser."
       </html:noScript>
    
      </contents>
    </dataScope>
  </baja:head>

  <baja:content xmlns="http://bali.us.oracle.com/cabo/marlin"
                xmlns:baja="http://bali.us.oracle.com/cabo/baja"
                xmlns:marlin="http://bali.us.oracle.com/cabo/marlin"
                xmlns:uix="http://bali.us.oracle.com/cabo/marlin"
                xmlns:html="http://www.w3.org/TR/REC-html40">

  <body onLoad="loadMe();"><contents>
   <script type="text/javascript"><contents>
    function loadMe()
    {
      //Read parent form elements
      var i, j;
      //var numOfForms = window.opener.document.forms.length;
      var numOfElementsInCurForm;
      var curForm;

      //Every calling page should handle his event
      var eventName = "initializeTargetSelection"; //default
      var curFormAction = document.forms[0].action;
      var eventStrIndex = curFormAction.indexOf("event=");
      if(eventStrIndex > 0)
      {
        eventName = curFormAction.substring(eventStrIndex+6);
      }

      //New form action for the parent form
      var newFormAction = window.opener.document.forms[0].action;
      urlquery=location.href.split("eventParam=");
      eventName = urlquery[1];    
      if(newFormAction.indexOf("?") > 0)
      {
        newFormAction = newFormAction + "&amp;event=" + eventName;
      }
      else
      {
        newFormAction = newFormAction + "?event=" + eventName;
      }

      //Write the parent form elements to iframe
      var d = frames.hiddenIFrame.document;
      d.write("&lt;html>&lt;body>");
      d.write("&lt;form action='" + newFormAction + "' target='_parent' method='POST'>");

      //We'll read UI elements from the first form only.
      for (i=0; i &lt; 1; i++)
      {
        curForm = window.opener.document.forms[i];
        numOfElementsInCurForm = curForm.elements.length;
        var singleQuoteIndex;
        var outStr = "";

        for (j=0; j &lt; numOfElementsInCurForm; j++)
        {
          //Replace single quote with escape sequence 
          singleQuoteIndex = 0; 
          if((curForm.elements[j].value != "")&amp;&amp;(curForm.elements[j].value.indexOf("'") >  0))
          {
            while((singleQuoteIndex=curForm.elements[j].value.indexOf("'")) > 0)
            {
              outStr = outStr + curForm.elements[j].value.substring(0,singleQuoteIndex) + "&amp;#39";
              curForm.elements[j].value = curForm.elements[j].value.substring(singleQuoteIndex+1, curForm.elements[j].value.length);
            }
            outStr = outStr + curForm.elements[j].value.substring(singleQuoteIndex+1, curForm.elements[j].value.length);
            curForm.elements[j].value = outStr;
          }

          if(curForm.elements[j].type!='select-one')
          {
            //Radio buttons
            if((curForm.elements[j].type=='radio')||(curForm.elements[j].type=='checkbox'))
            {
              if(curForm.elements[j].checked)
              {
                d.write("&lt;input type='" + curForm.elements[j].type + "' name='" + curForm.elements[j].name + "' value='" + curForm.elements[j].value + "' checked />");
              }
              else
              {
                d.write("&lt;input type='" + curForm.elements[j].type + "' name='" + curForm.elements[j].name + "' value='" + curForm.elements[j].value + "'/>");
              }
            }
            else if(curForm.elements[j].type=='textarea')
            {
              d.write("&lt;textarea name='" + curForm.elements[j].name + "'>" + curForm.elements[j].value + "&lt;/textarea>");
            }
            else
            {
              d.write("&lt;input type='" + curForm.elements[j].type + "' name='" + curForm.elements[j].name + "' value='" + curForm.elements[j].value + "'/>");
            }
          } 
          else 
          {
            d.write("&lt;select name='" + curForm.elements[j].name + "'>&lt;option value='" + curForm.elements[j].value + "' selected>&lt;/select>");
          }
        }
      }
      d.write("&lt;form>&lt;body>&lt;html>");
      d.close();

     //Submit the form in the iframe
     d.forms[0].submit();
    }
   </contents></script>

   <dataScope><contents>
    <form name="postBackWithEvent"
          xmlns="http://xmlns.oracle.com/uix/ui"
          method="POST"><contents>
      <html:iframe  title="Intermediate Page" frameborder="0" 
                   name="hiddenIFrame" 
                   src="" 
                   width="0" 
                   height="0"/>
    </contents></form>
   </contents></dataScope>
  </contents></body>
 </baja:content>
</page>
