<?php
##############################################################
##In-portal                                     			##
##############################################################
##                   In-portal                     			##
##             Intechnic Corporation               			##
##          All Rights Reserved, 1998-2002            		##
##                                           				## 
## No portion of this code may be copied, reproduced or		## 
##    otherwise redistributed without proper written		##
##   consent of Intechnic Corporation.  Violation will      ##
##    result in revocation of the license and support		##
##  privileges along maximum prosecution allowed by law.	##
##############################################################

define('IS_POPUP', 1);

// new startup: begin
define('REL_PATH', 'admin/editor');
$relation_level = count( explode('/', REL_PATH) );
define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) );
require_once FULL_PATH.'/kernel/startup.php';
// new startup: end

require_once ($pathtoroot.$admin."/include/elements.php"); 
require_once ($pathtoroot."kernel/admin/include/navmenu.php"); 
require_once($pathtoroot.$admin."/toolbar.php");
require_once($pathtoroot.$admin."/editor/FCKeditor/fckeditor.php");

$style_sheet_global = $adminURL."/include/style.css";
?>
<html>
   <head>
      <title>Online Editor</title>
      <?php print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$style_sheet_global\">\n"; ?>
      <?php require_once($pathtoroot.$admin."/include/mainscript.php"); ?>
      <script>
      function HasParam(param)
	{
		// checks of parameter is passed to function (cross-browser)
		return typeof(param) == 'undefined' ? false : true;
	}
      </script>
   </head>
   <body marginwidth="0" leftmargin="0" topmargin="0" marginheight="0" style="overflow:auto">
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0" align="center"><tr><td align="left" valign="top">
<?php
   $section=$_GET["section"];
   $objListToolBar = new clsToolBar();

   $objListToolBar->Set("section",$section);
   $objListToolBar->Set("load_menu_func","");
   $objListToolBar->Set("CheckClass","");
  
   $listImages = array();
                    //$img, $alt, $link, $onMouseOver, $onMouseOut, $onClick

   $objListToolBar->Add("select", "la_ToolTip_Select","#","swap('select','toolbar/tool_select_f2.gif');",
                        "swap('select', 'toolbar/tool_select.gif');",
                        "document.frm.submit();","tool_select.gif");

   $objListToolBar->Add("cancel", "la_ToolTip_Stop","#","swap('cancel','toolbar/tool_stop_f2.gif');",
                    "swap('cancel', 'toolbar/tool_stop.gif');","window.close();","tool_stop.gif");

   $title = "Online HTML Editor";

   $objSections->SetCurrentSection($section);
   print $objSections->section_header($envar,NULL,$title);
   $TargetForm = $_GET["TargetForm"];
   $TargetField = $_GET["TargetField"];
   echo $objListToolBar->Build();
?>
  <form name="frm" action="javascript:update_opener();">
<?php  
   $oFCKeditor = new FCKeditor();
   $oFCKeditor->Value = '' ;
   $oFCKeditor->CreateFCKeditor( 'Content', '100%','80%' ) ;            
?>	
	</FORM>  
      </td></tr></table>
      
    </form>

   </body>
   <script>
<?php
print <<<END
   function update_content()
   {
     if (window.opener)
     {
        if (!window.opener.closed)
        {
           bf = window.opener.document.$TargetForm;
//           if (typeof (bf.$TargetField.value) != 'undefined') {
//           	current = bf.$TargetField.value;
//           }
//           else {
						current = window.opener.document.getElementById('$TargetField').value;
//           }
           //f = document.getElementById('editform');
           d = document.getElementById('Content');
           d.value = current;
        } 
        else 
        	window.close()
     }
     else 
     	window.close()
    }
         
    function update_opener()
    {       
       d = document.getElementById('Content');      
       if (d.form)
         if (d.form.onsubmit)
            d.form.onsubmit()

       if (!window.opener) return;
       if (!window.opener.closed)
       
//       if (typeof (bf.$TargetField.value) != 'undefined') {
//         current = bf.$TargetField;
//       }
//       else {
				current = window.opener.document.getElementById('$TargetField');
//       }
       
       current.value = d.value;
       //alert('Setting bf.$TargetField.value to'+d.value); 	
       window.close();
    }
         
END;
?>
   setTimeout('update_content();',100);
   </script>
</html>