Committed a bunch of bugfixes and new features related to IRRE
authorIngmar Schlecht <ingmar.schlecht@typo3.org>
Thu, 14 Dec 2006 20:01:29 +0000 (20:01 +0000)
committerIngmar Schlecht <ingmar.schlecht@typo3.org>
Thu, 14 Dec 2006 20:01:29 +0000 (20:01 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@1881 709f56b5-9817-0410-a4d7-c38de5d9e867

13 files changed:
ChangeLog
t3lib/class.t3lib_loaddbgroup.php
t3lib/class.t3lib_refindex.php
t3lib/class.t3lib_tceforms.php
t3lib/class.t3lib_tceforms_inline.php
t3lib/class.t3lib_tcemain.php
t3lib/jsfunc.inline.js
typo3/alt_doc.php
typo3/alt_doc_ajax.php
typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php
typo3/sysext/rtehtmlarea/htmlarea/htmlarea-compressed.js
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
typo3/template.php

index 4482a17..8652dd2 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-12-14  Ingmar Schlecht  <ingmar@typo3.org>
+
+       * Committed a bunch of bugfixes and new features related to IRRE (Thanks to Oliver Hader!):
+               - Automatic sorting by a "sortby" field (e.g. the title)
+               - The possibility to have relations from different parent pages to a child table
+               - Expanded/collapsed states are saved in uc now
+               - Bugfixes to #4616 and #4617 concerning IRRE relation to the same table
+               - Bugfix for using RTEs in IRRE records (works even inside of nested tabs now)
 
 2006-12-13  Martin Kutschker  <martin.t.kutschker@blackbox.net>
 
index 8620fc4..e1bb57f 100755 (executable)
@@ -167,6 +167,10 @@ class t3lib_loadDBGroup    {
                } else {
                                // If not MM, then explode the itemlist by "," and traverse the list:
                        $this->readList($itemlist);
+                               // do automatic default_sortby, if any
+                       if ($conf['foreign_default_sortby']) {
+                               $this->sortList($conf['foreign_default_sortby']);
+                       }
                }
        }
 
@@ -215,6 +219,38 @@ class t3lib_loadDBGroup    {
        }
 
        /**
+        * Does a sorting on $this->itemArray depending on a default sortby field.
+        * This is only used for automatic sorting of comma separated lists.
+        * This function is only relevant for data that is stored in comma separated lists!
+        * 
+        * @param       string          $sortby: The default_sortby field/command (e.g. 'price DESC')
+        * @return      void
+        */
+       function sortList($sortby) {
+                       // sort directly without fetching addional data
+               if ($sortby == 'uid') {
+                       usort($this->itemArray, create_function('$a,$b', 'return $a["id"] < $b["id"] ? -1 : 1;'));
+                       // only useful if working on the same table
+               } elseif (count($this->tableArray) == 1) {
+                       reset($this->tableArray);
+                       $table = key($this->tableArray);
+                       $uidList = implode(',', current($this->tableArray));
+
+                       if ($uidList) {
+                               $this->itemArray = array();
+                               $this->tableArray = array();
+                               
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, 'uid IN ('.$uidList.')', '', $sortby);
+                               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                                       $this->itemArray[] = array('id' => $row['uid'], 'table' => $table);
+                                       $this->tableArray[$table][] = $row['uid'];
+                               }
+                               $GLOBALS['TYPO3_DB']->sql_free_result($res);
+                       }
+               }
+       }
+
+       /**
         * Reads the record tablename/id into the internal arrays itemArray and tableArray from MM records.
         * You can call this function after start if you supply no list to start()
         *
@@ -371,73 +407,59 @@ class t3lib_loadDBGroup   {
        function readForeignField($uid, $conf) {
                $key = 0;
                $uid = intval($uid);
+               $whereClause = '';
                $foreign_table = $conf['foreign_table'];
+               $foreign_table_field = $conf['foreign_table_field'];
                $useDeleteClause = $this->undeleteRecord ? false : true;
 
-               if ($conf['foreign_sortby'])                                                                            // specific sortby for data handled by this field
-                       $sortby = $conf['foreign_sortby'];
-               elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['sortby'])                      // specific sortby for all table records
+                       // search for $uid in foreign_field, and if we have symmetric relations, do this also on symmetric_field
+               if ($conf['symmetric_field']) {
+                       $whereClause = '('.$conf['foreign_field'].'='.$uid.' OR '.$conf['symmetric_field'].'='.$uid.')';
+               } else {
+                       $whereClause = $conf['foreign_field'].'='.$uid;
+               }
+                       // use the deleteClause (e.g. "deleted=0") on this table
+               if ($useDeleteClause) {
+                       $whereClause .= t3lib_BEfunc::deleteClause($foreign_table);
+               }
+                       // if it's requested to look for the parent uid AND the parent table,
+                       // add an additional SQL-WHERE clause
+               if ($foreign_table_field && $this->currentTable) {
+                       $whereClause .= ' AND '.$foreign_table_field.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->currentTable, $foreign_table);
+               }
+               
+                       // get the correct sorting field
+               if ($conf['foreign_sortby']) {                                                                                  // specific manual sortby for data handled by this field
+                       if ($conf['symmetric_sortby'] && $conf['symmetric_field']) {
+                                       // sorting depends on, from which side of the relation we're looking at it
+                               $sortby = '
+                                       CASE
+                                               WHEN '.$conf['foreign_field'].'='.$uid.'
+                                               THEN '.$conf['foreign_sortby'].'
+                                               ELSE '.$conf['symmetric_sortby'].'
+                                       END';
+                       } else {
+                                       // regular single-side behaviour
+                               $sortby = $conf['foreign_sortby'];
+                       }
+               } elseif ($conf['foreign_default_sortby']) {                                                    // specific default sortby for data handled by this field
+                       $sortby = $conf['foreign_default_sortby'];
+               } elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['sortby']) {                  // manual sortby for all table records
                        $sortby = $GLOBALS['TCA'][$foreign_table]['ctrl']['sortby'];
-               elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['default_sortby'])      // default sortby for all table records
+               } elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['default_sortby']) {  // default sortby for all table records
                        $sortby = $GLOBALS['TCA'][$foreign_table]['ctrl']['default_sortby'];
+               }
 
                        // strip a possible "ORDER BY" in front of the $sortby value
                $sortby = $GLOBALS['TYPO3_DB']->stripOrderBy($sortby);
-
                        // get the rows from storage
-               $rows = t3lib_BEfunc::getRecordsByField($foreign_table,$conf['foreign_field'],$uid,'','',$sortby,'',$useDeleteClause);
-
-                       // Handle symmetric relations
-               if ($conf['symmetric_field']) {
-                       $symSortby = $conf['symmetric_sortby'] ? $conf['symmetric_sortby'] : $sortby;
-                       $symRows = t3lib_BEfunc::getRecordsByField($foreign_table,$conf['symmetric_field'],$uid,'','',$symSortby,'',$useDeleteClause);
-
-                       if (count($symRows)) {
-                                       // if there are rows and symRows, we have to merge them, but keeping the sorting order
-                               if (count($rows)) {
-                                       $newRows = array();
-                                       reset($rows);
-                                       reset($symRows);
-
-                                       $row = current($rows);
-                                       $symRow = current($symRows);
-
-                                       while (is_array($row)) {
-                                                       // if the sorting value of the symRow is lower than the row sorting value, insert symRow before
-                                               while (is_array($symRow) && $symRow[$symSortby] <= $row[$sortby]) {
-                                                       $newRows[] = $symRow;
-                                                       $symRow = next($symRows);
-                                               }
-
-                                                       // all better sorted symRows have been processed, now add the row itself
-                                               $newRows[] = $row;
-                                               $row = next($rows);
-
-                                                       // if there are no more rows, paste all remaining symRows
-                                               if ($row == false && $symRow != false) {
-                                                       while (is_array($symRow)) {
-                                                               $newRows[] = $symRow;
-                                                               $symRow = next($symRows);
-                                                       }
-                                               }
-                                       }
-
-                                               // set the rows value to the new ordered array
-                                       $rows = $newRows;
-
-                                       // there are no rows, just symRows, so we use them - sorting comes from database
-                               } else {
-                                       $rows = $symRows;
-
-                               }
-                       }
-               }
+               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $foreign_table, $whereClause, '', $sortby);
 
                if (count($rows)) {
                        foreach ($rows as $row) {
                                $this->itemArray[$key]['id'] = $row['uid'];
-                               $this->itemArray[$key]['table'] = $conf['foreign_table'];
-                               $this->tableArray[$theTable][]= $row['uid'];
+                               $this->itemArray[$key]['table'] = $foreign_table;
+                               $this->tableArray[$foreign_table][]= $row['uid'];
                                $key++;
                        }
                }
@@ -449,13 +471,15 @@ class t3lib_loadDBGroup   {
         * @param       array           $conf: TCA configuration for current field
         * @param       integer         $parentUid: The uid of the parent record
         * @param       boolean         $updateForeignField: Whether to update the foreign field with the $parentUid (on Copy)
+        * @param       boolean         $skipSorting: Do not update the sorting columns, this could happen for imported values
         * @return      void
         */
-       function writeForeignField($conf, $parentUid, $updateToUid=0) {
+       function writeForeignField($conf, $parentUid, $updateToUid=0, $skipSorting=false) {
                $c = 0;
                $foreign_table = $conf['foreign_table'];
                $foreign_field = $conf['foreign_field'];
                $symmetric_field = $conf['symmetric_field'];
+               $foreign_table_field = $conf['foreign_table_field'];
 
                        // if there are table items and we have a proper $parentUid
                if (t3lib_div::testInt($parentUid) && count($this->tableArray)) {
@@ -476,7 +500,8 @@ class t3lib_loadDBGroup     {
 
                                $updateValues = array();
 
-                                       // no update to a foreign_field/symmetric_field pointer is requested -> just sorting
+                                       // no update to the uid is requested, so this is the normal behaviour
+                                       // just update the fields and care about sorting
                                if (!$updateToUid) {
                                                // Always add the pointer to the parent uid
                                        if ($isOnSymmetricSide) {
@@ -484,22 +509,30 @@ class t3lib_loadDBGroup   {
                                        } else {
                                                $updateValues[$foreign_field] = $parentUid;
                                        }
-
-                                               // specific sortby for data handled by this field
-                                       if ($conf['foreign_sortby']) {
-                                               $sortby = $conf['foreign_sortby'];
-                                       } elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['sortby']) { // specific sortby for all table records
-                                               $sortby = $GLOBALS['TCA'][$foreign_table]['ctrl']['sortby'];
+                                       
+                                               // if it is configured in TCA also to store the parent table in the child record, just do it
+                                       if ($foreign_table_field && $this->currentTable) {
+                                               $updateValues[$foreign_table_field] = $this->currentTable;
                                        }
-                                               // strip a possible "ORDER BY" in front of the $sortby value
-                                       $sortby = $GLOBALS['TYPO3_DB']->stripOrderBy($sortby);
-                                       $symSortby = $conf['symmetric_sortby'];
-
-                                               // set the sorting on the right side, it depends on who created the relation, so what uid is in the symmetric_field
-                                       if ($isOnSymmetricSide && $symSortby) {
-                                               $updateValues[$symSortby] = ++$c;
-                                       } elseif ($sortby) {
-                                               $updateValues[$sortby] = ++$c;
+
+                                               // update sorting columns if not to be skipped
+                                       if (!$skipSorting) {
+                                                       // get the correct sorting field
+                                               if ($conf['foreign_sortby']) {                                                                  // specific manual sortby for data handled by this field 
+                                                       $sortby = $conf['foreign_sortby'];
+                                               } elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['sortby']) {  // manual sortby for all table records
+                                                       $sortby = $GLOBALS['TCA'][$foreign_table]['ctrl']['sortby'];
+                                               }
+                                                       // strip a possible "ORDER BY" in front of the $sortby value
+                                               $sortby = $GLOBALS['TYPO3_DB']->stripOrderBy($sortby);
+                                               $symSortby = $conf['symmetric_sortby'];
+       
+                                                       // set the sorting on the right side, it depends on who created the relation, so what uid is in the symmetric_field
+                                               if ($isOnSymmetricSide && $symSortby) {
+                                                       $updateValues[$symSortby] = ++$c;
+                                               } elseif ($sortby) {
+                                                       $updateValues[$sortby] = ++$c;
+                                               }
                                        }
 
                                        // update to a foreign_field/symmetric_field pointer is requested, normally used on record copies
index 078c878..8760c51 100755 (executable)
@@ -202,12 +202,8 @@ class t3lib_refindex {
                                                // Based on type,
                                        switch((string)$dat['type'])    {
                                                case 'db':
-                                               case 'select':
                                                        $this->createEntryData_dbRels($table,$uid,$fieldname,'',$deleted,$dat['itemArray']);
                                                break;
-                                               case 'inline':
-                                                       $this->createEntryData_inlineRels($table,$uid,$fieldname,'',$deleted,$dat['itemArray']);
-                                               break;
                                                case 'file':
                                                        $this->createEntryData_fileRels($table,$uid,$fieldname,'',$deleted,$dat['newValueFiles']);
                                                break;
index 93d6bb7..699e128 100755 (executable)
@@ -284,6 +284,7 @@ class t3lib_TCEforms        {
        var $requiredElements=array();                          // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
        var $renderDepth=0;                                                     // Keeps track of the rendering depth of nested records.
        var $savedSchemes=array();                                      // Color scheme buffer.
+       var $dynTabLevelStack = array();                        // holds tab dividers which were cascaded, required for RTE&IRRE
 
                // Internal, registers for user defined functions etc.
        var $additionalCode_pre = array();                      // Additional HTML code, printed before the form.
@@ -471,6 +472,12 @@ class t3lib_TCEforms       {
                        if ($TCA[$table]['types'][$typeNum])    {
                                $itemList = $TCA[$table]['types'][$typeNum]['showitem'];
                                if ($itemList)  {       // If such a list existed...
+                                               // if TCEforms will render a tab menu in the next step, push the name to the tab stack
+                                       if (strstr($itemList, '--div--') !== false && $this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs']) {
+                                               $tabIdentString = 'TCEforms:'.$table.':'.$row['uid'];
+                                               $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId('TCEforms:'.$table.':'.$row['uid']);
+                                               $this->dynTabLevelStack[$tabIdentStringMD5] = 1;
+                                       }
 
                                                // Explode the field list and possibly rearrange the order of the fields, if configured for
                                        $fields = t3lib_div::trimExplode(',',$itemList,1);
@@ -524,6 +531,8 @@ class t3lib_TCEforms        {
                                                                        if ($this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs'])      {
                                                                                $this->wrapBorder($out_array[$out_sheet],$out_pointer);
                                                                                $out_sheet++;
+                                                                                       // remember what sheet we're currently in
+                                                                               $this->dynTabLevelStack[$tabIdentStringMD5] = $out_sheet+1;
                                                                                $out_array[$out_sheet] = array();
                                                                                $out_array_meta[$out_sheet]['title'] = $this->sL($parts[1]);
                                                                        }
@@ -597,10 +606,13 @@ class t3lib_TCEforms      {
                                );
                        }
 
+                               // unset the current level of tab menus
+                       unset($this->dynTabLevelStack[$tabIdentStringMD5]);
+
                        return '
                                <tr>
                                        <td colspan="2">
-                                       '.$this->getDynTabMenu($parts, 'TCEforms:'.$table.':'.$row['uid']).'
+                                       '.$this->getDynTabMenu($parts, $tabIdentString).'
                                        </td>
                                </tr>';
                } else {        // Only one, so just implode:
@@ -5549,6 +5561,21 @@ class t3lib_TCEforms     {
                }
                return $this->cachedAdditionalPreviewLanguages;
        }
+       
+       /**
+        * Get a list, depending on $this->dynTabLevelStack, that has the information
+        * in which tab (--div--) fields are inserted.
+        *
+        * @param       string          $appendString: String to append for each item
+        * @return      string          A list of cascaded tab divs, like "DTM-2e8791854a-1,DTM-f3c79a0523-4"
+        */
+       function getDynTabLevelState($appendString = '') {
+               $levels = array();
+               foreach ($this->dynTabLevelStack as $tabIdent => $divId) {
+                       $levels[] = $tabIdent.'-'.$divId.$appendString;
+               }
+               return implode(',', $levels);
+       }
 }
 
 
index 7c5dc16..4457807 100644 (file)
@@ -25,7 +25,7 @@
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
 /**
- * The Inline-Relational-Record-Editing functions as part of the TCEforms.
+ * The Inline-Relational-Record-Editing (IRRE) functions as part of the TCEforms.
  *
  * @author     Oliver Hader <oh@inpublica.de>
  */
@@ -93,7 +93,9 @@ class t3lib_TCEforms_inline {
        var $inlineFirstPid;                                    // the first call of an inline type appeared on this page (pid of record)
        var $inlineNames = array();                             // keys: form, object -> hold the name/id for each of them
        var $inlineData = array();                              // inline data array used for JSON output
+       var $inlineView = array();                              // expanded/collapsed states for the current BE user
        var $inlineCount = 0;                                   // count the number of inline types used
+       var $inlineStyles = array();
 
        var $prependNaming = 'data';                    // how the $this->fObj->prependFormFieldNames should be set ('data' is default)
        var $prependFormFieldNames;                             // reference to $this->fObj->prependFormFieldNames
@@ -111,6 +113,8 @@ class t3lib_TCEforms_inline {
                $this->backPath =& $tceForms->backPath;
                $this->prependFormFieldNames =& $this->fObj->prependFormFieldNames;
                $this->prependCmdFieldNames =& $this->fObj->prependCmdFieldNames;
+               
+               $this->inlineStyles['margin-right'] = '5';
        }
 
 
@@ -143,6 +147,12 @@ class t3lib_TCEforms_inline {
                        // remember the page id (pid of record) where inline editing started first
                        // we need that pid for ajax calls, so that they would know where the action takes place on the page structure
                if (!isset($this->inlineFirstPid)) {
+                               // if this record is not new, try to fetch the inlineView states
+                               // @TODO: Add checking/cleaning for unused tables, records, etc. to save space in uc-field
+                       if (t3lib_div::testInt($row['uid'])) {
+                               $inlineView = unserialize($GLOBALS['BE_USER']->uc['inlineView']);
+                               $this->inlineView = $inlineView[$table][$row['uid']];
+                       }
                                // if pid is negative, fetch the previous record and take its pid
                        if ($row['pid'] < 0) {
                                $prevRec = t3lib_BEfunc::getRecord($table, abs($row['pid']));
@@ -165,11 +175,16 @@ class t3lib_TCEforms_inline {
                $config['inline']['last'] = $recordList[count($recordList)-1]['uid'];
 
                        // tell the browser what we have (using JSON later)
+               $top = $this->getStructureLevel(0);
                $this->inlineData['config'][$nameObject] = array('table' => $foreign_table);
                $this->inlineData['config'][$nameObject.'['.$foreign_table.']'] = array(
                        'min' => $minitems,
                        'max' => $maxitems,
                        'sortable' => $config['appearance']['useSortable'],
+                       'top' => array(
+                               'table' => $top['table'],
+                               'uid'   => $top['uid'],
+                       ),
                );
 
                        // if relations are required to be unique, get the uids that have already been used on the foreign side of the relation
@@ -287,16 +302,26 @@ class t3lib_TCEforms_inline {
                $fields = $this->wrapFormsSection($fields);
 
                if ($isNewRecord) {
+                               // show this record expanded or collapsed
+                       $isExpanded = is_array($config['appearance']) && $config['appearance']['collapseAll'] ? 1 : 0;
+                               // get the top parent table
+                       $top = $this->getStructureLevel(0);
+                       $ucFieldName = 'uc['.$top['table'].']['.$top['uid'].']'.$appendFormFieldNames;
+                               // set additional fields for processing for saving
                        $fields .= '<input type="hidden" name="'.$this->prependFormFieldNames.$appendFormFieldNames.'[pid]" value="'.$rec['pid'].'"/>';
+                       $fields .= '<input type="hidden" name="'.$ucFieldName.'" value="'.$isExpanded.'" />';
+
                } else {
+                               // show this record expanded or collapsed
+                       $isExpanded = $this->getExpandedCollapsedState($foreign_table, $rec['uid']);
+                               // set additional field for processing for saving
                        $fields .= '<input type="hidden" name="'.$this->prependCmdFieldNames.$appendFormFieldNames.'[delete]" value="1" disabled="disabled" />';
                }
+               
+                       // if this record should be shown collapsed
+               if (!$isExpanded) $appearanceStyleFields = ' style="display: none;"';
 
-                       // set the appearance style of the records of this table
-               if (is_array($config['appearance']) && count($config['appearance'])) {
-                       if ($config['appearance']['collapseAll']) $appearanceStyleFields = ' style="display: none;"';
-               }
-
+                       // set the record container with data for output
                $out = '<div id="'.$formFieldNames.'_header">'.$header.'</div>';
                $out .= '<div id="'.$formFieldNames.'_fields"'.$appearanceStyleFields.'>'.$fields.$combination.'</div>';
                        // wrap the header, fields and combination part of a child record with a div container
@@ -312,30 +337,45 @@ class t3lib_TCEforms_inline {
         *
         * @param       string          $parentUid: The uid of the parent (embedding) record (uid or NEW...)
         * @param       string          $foreign_table: The foreign_table we create a header for
-        * @param       array           $rec: The current record of that table
+        * @param       array           $rec: The current record of that foreign_table
         * @param       array           $config: content of $PA['fieldConf']['config']
         * @return      string          The HTML code of the header
         */
-       function renderForeignRecordHeader($parentUid, $foreign_table,$rec,$config = array()) {
+       function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config = array()) {
+                       // Init:
                $formFieldNames = $this->inlineNames['object'].'['.$foreign_table.']['.$rec['uid'].']';
                $expandSingle = $config['appearance']['expandSingle'] ? 1 : 0;
                $onClick = "return inline.expandCollapseRecord('".htmlspecialchars($formFieldNames)."', $expandSingle)";
 
-                       // if an alternative label for the field we render is set, use it
+                       // Pre-Processing:
                $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec);
-               if (!$isOnSymmetricSide && $config['foreign_label']) {
-                       $titleCol = $config['foreign_label'];
-               } elseif ($isOnSymmetricSide && $config['symmetric_label']) {
-                       $titleCol = $config['symmetric_label'];
-               }
-
+               $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? true : false;
+               $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? true : false;
+               
+                       // Get the record title/label for a record:
+                       
+                       // render using a self-defined user function
+               if ($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc']) {
+                       $params = array(
+                               'table' => $foreign_table,
+                               'row'   => $rec,
+                               'title' => '',
+                               'isOnSymmetricSide' => $isOnSymmetricSide
+                       );
+                       $null = null;   // callUserFunction requires a third parameter, but we don't want to give $this as reference!
+                       t3lib_div::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
+                       $recTitle = $params['title'];
+                       
                        // render the special alternative title
-               if (isset($titleCol)) {
+               } elseif ($hasForeignLabel || $hasSymmetricLabel) {
+                       $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
                        $recTitle = t3lib_BEfunc::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol]);
+                       $recTitle = t3lib_BEfunc::getRecordTitlePrep($recTitle);
                        $recTitle = $this->fObj->noTitle($recTitle);
+                       
                        // render the standard
                } else {
-                       $recTitle = t3lib_BEfunc::getRecordTitle($foreign_table, $rec);
+                       $recTitle = t3lib_BEfunc::getRecordTitle($foreign_table, $rec, true);
                }
 
                $altText = t3lib_BEfunc::getRecordIconAltText($rec, $foreign_table);
@@ -347,14 +387,14 @@ class t3lib_TCEforms_inline {
 
                $label =
                        '<a href="#" onclick="'.htmlspecialchars($onClick).'" style="display: block;">'.
-                       //      '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' align="absmiddle" /> '.
                                '<span id="'.$formFieldNames.'_label">'.$recTitle.'</span>'.
                        '</a>';
 
-               $ctrl = $this->renderForeignRecordHeaderControl($foreign_table,$rec,$config);
+               $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config);
 
+                       // @TODO: Check the table wrapping and the CSS definitions
                $header =
-                       '<table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-right: 5px;"'.
+                       '<table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-right: '.$this->inlineStyles['margin-right'].'px;"'.
                        ($this->fObj->borderStyle[2] ? ' background="'.htmlspecialchars($this->backPath.$this->fObj->borderStyle[2]).'"':'').
                        ($this->fObj->borderStyle[3] ? ' class="'.htmlspecialchars($this->fObj->borderStyle[3]).'"':'').'>' .
                        '<tr class="class-main12"><td width="18">'.$iconImg.'</td><td align="left"><b>'.$label.'</b></td><td align="right">'.$ctrl.'</td></tr></table>';
@@ -367,121 +407,116 @@ class t3lib_TCEforms_inline {
         * Render the control-icons for a record header (create new, sorting, delete, disable/enable).
         * Most of the parts are copy&paste from class.db_list_extra.inc and modified for the JavaScript calls here
         *
-        * @param       string          $table: The table (foreign_table) we create control-icons for
-        * @param       array           $row: The current record of that table
+        * @param       string          $parentUid: The uid of the parent (embedding) record (uid or NEW...)
+        * @param       string          $foreign_table: The table (foreign_table) we create control-icons for
+        * @param       array           $rec: The current record of that foreign_table
         * @param       array           $config: (modified) TCA configuration of the field
         * @return      string          The HTML code with the control-icons
         */
-       function renderForeignRecordHeaderControl($table,$row,$config = array()) {
-               global $TCA, $SOBE;
-
+       function renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config = array()) {
                        // Initialize:
                $cells=array();
-               $isNewItem = substr($row['uid'], 0, 3) == 'NEW';
+               $isNewItem = substr($rec['uid'], 0, 3) == 'NEW';
 
-               $nameObjectFt = $this->inlineNames['object'].'['.$table.']';
-               $nameObjectFtId = $nameObjectFt.'['.$row['uid'].']';
+               $tcaTableCtrl =& $GLOBALS['TCA'][$foreign_table]['ctrl'];
+               $tcaTableCols =& $GLOBALS['TCA'][$foreign_table]['columns'];
+               
+               $isPagesTable = $foreign_table == 'pages' ? true : false;
+               $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec);
+               $enableManualSorting = $tcaTableCtrl['sortby'] || $config['MM'] || (!$isOnSymmetricSide && $config['foreign_sortby']) || ($isOnSymmetricSide && $config['symmetric_sortby']) ? true : false;
+               
+               $nameObjectFt = $this->inlineNames['object'].'['.$foreign_table.']';
+               $nameObjectFtId = $nameObjectFt.'['.$rec['uid'].']';
 
                $calcPerms = $GLOBALS['BE_USER']->calcPerms(
-                       t3lib_BEfunc::readPageAccess($row['pid'], $GLOBALS['BE_USER']->getPagePermsClause(1))
+                       t3lib_BEfunc::readPageAccess($rec['pid'], $GLOBALS['BE_USER']->getPagePermsClause(1))
                );
 
                        // FIXME: Put these calls somewhere else... possibly they arn't needed here
-               $web_list_modTSconfig = t3lib_BEfunc::getModTSconfig($row['pid'],'mod.web_list');
+               $web_list_modTSconfig = t3lib_BEfunc::getModTSconfig($rec['pid'],'mod.web_list');
                $allowedNewTables = t3lib_div::trimExplode(',',$this->fObj->web_list_modTSconfig['properties']['allowedNewTables'],1);
-               $showNewRecLink = !count($allowedNewTables) || in_array($table, $allowedNewTables);
+               $showNewRecLink = !count($allowedNewTables) || in_array($foreign_table, $allowedNewTables);
 
                        // If the listed table is 'pages' we have to request the permission settings for each page:
-               if ($table=='pages')    {
-                       $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
+               if ($isPagesTable)      {
+                       $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$rec['uid']));
                }
 
                        // This expresses the edit permissions for this particular element:
-               $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($calcPerms&16));
-
-                       // "Show" link (only pages and tt_content elements)
-               if ($table=='pages' || $table=='tt_content')    {
-                       $params='&edit['.$table.']['.$row['uid'].']=edit';
-                       $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($table=='tt_content'?$this->id.'#'.$row['uid']:$row['uid'])).'">'.
-                                       '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'" alt="" />'.
-                                       '</a>';
-               }
+               $permsEdit = ($isPagesTable && ($localCalcPerms&2)) || (!$isPagesTable && ($calcPerms&16));
 
                        // "Info": (All records)
                if (!$isNewItem)
-                       $cells[]='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'">'.
+                       $cells[]='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$foreign_table.'\', \''.$rec['uid'].'\'); return false;').'">'.
                                '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:showInfo',1).'" alt="" />'.
                                '</a>';
 
                        // If the table is NOT a read-only table, then show these links:
-               if (!$TCA[$table]['ctrl']['readOnly'])  {
+               if (!$tcaTableCtrl['readOnly']) {
 
                                // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row or if default values can depend on previous record):
-                       if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues'])       {
+                       if ($enableManualSorting || $tcaTableCtrl['useColumnsForDefaultValues'])        {
                                if (
-                                       ($table!='pages' && ($calcPerms&16)) ||         // For NON-pages, must have permission to edit content on this parent page
-                                       ($table=='pages' && ($calcPerms&8))             // For pages, must have permission to create new pages here.
+                                       (!$isPagesTable && ($calcPerms&16)) ||  // For NON-pages, must have permission to edit content on this parent page
+                                       ($isPagesTable && ($calcPerms&8))               // For pages, must have permission to create new pages here.
                                        )       {
                                        if ($showNewRecLink)    {
-                                               $onClick = "return inline.createNewRecord('".$nameObjectFt."','".$row['uid']."')";
-                                               $params='&edit['.$table.']['.(-$row['uid']).']=new';
+                                               $onClick = "return inline.createNewRecord('".$nameObjectFt."','".$rec['uid']."')";
                                                $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'" class="inlineNewButton"'.$config['inline']['inlineNewButtonStyle'].'>'.
-                                                               '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:new'.($table=='pages'?'Page':'Record'),1).'" alt="" />'.
+                                                               '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($isPagesTable?'page':'el').'.gif','width="'.($isPagesTable?13:11).'" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:new'.($isPagesTable?'Page':'Record'),1).'" alt="" />'.
                                                                '</a>';
                                        }
                                }
                        }
 
                                // Drag&Drop Sorting: Sortable handler for script.aculo.us
-                       if ($permsEdit && $config['appearance']['useSortable'] && ($TCA[$table]['ctrl']['sortby'] || $config['MM']))    {
+                       if ($permsEdit && $enableManualSorting && $config['appearance']['useSortable']) {
                                $cells[] = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/move.gif','width="16" height="16" hspace="2"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.move',1).'" alt="" style="cursor: move;" class="sortableHandle" />';
                        }
 
                                // "Up/Down" links
-                       if ($permsEdit && ($TCA[$table]['ctrl']['sortby'] || $config['MM']))    {
+                       if ($permsEdit && $enableManualSorting) {
                                $onClick = "return inline.changeSorting('".$nameObjectFtId."', '1')";   // Up
-                               $style = $config['inline']['first'] == $row['uid'] ? 'style="visibility: hidden;"' : '';
+                               $style = $config['inline']['first'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
                                $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'" class="sortingUp" '.$style.'>'.
                                                '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:moveUp',1).'" alt="" />'.
                                                '</a>';
 
                                $onClick = "return inline.changeSorting('".$nameObjectFtId."', '-1')";  // Down
-                               $style = $config['inline']['last'] == $row['uid'] ? 'style="visibility: hidden;"' : '';
+                               $style = $config['inline']['last'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
                                $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'" class="sortingDown" '.$style.'>'.
                                                '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:moveDown',1).'" alt="" />'.
                                                '</a>';
                        }
 
                                // "Hide/Unhide" links:
-                       $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
-                       if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField)))     {
+                       $hiddenField = $tcaTableCtrl['enablecolumns']['disabled'];
+                       if ($permsEdit && $hiddenField && $tcaTableCols[$hiddenField] && (!$tcaTableCols[$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$foreign_table.':'.$hiddenField))) {
                                $onClick = "return inline.enableDisableRecord('".$nameObjectFtId."')";
-                               if ($row[$hiddenField]) {
-                                       $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
+                               if ($rec[$hiddenField]) {
                                        $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
-                                                       '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:unHide'.($table=='pages'?'Page':''),1).'" alt="" id="'.$nameObjectFtId.'_disabled" />'.
+                                                       '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:unHide'.($isPagesTable?'Page':''),1).'" alt="" id="'.$nameObjectFtId.'_disabled" />'.
                                                        '</a>';
                                } else {
-                                       $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
                                        $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
-                                                       '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:hide'.($table=='pages'?'Page':''),1).'" alt="" id="'.$nameObjectFtId.'_disabled" />'.
+                                                       '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:hide'.($isPagesTable?'Page':''),1).'" alt="" id="'.$nameObjectFtId.'_disabled" />'.
                                                        '</a>';
                                }
                        }
 
                                // "Delete" link:
                        if (
-                               ($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($calcPerms&16))
+                               ($isPagesTable && ($localCalcPerms&4)) || (!$isPagesTable && ($calcPerms&16))
                                )       {
                                $onClick = "inline.deleteRecord('".$nameObjectFtId."');";
-                               $cells[]='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning').t3lib_BEfunc::referenceCount($table,$row['uid'],' (There are %s reference(s) to this record!)')).')) {   '.$onClick.' } return false;').'">'.
+                               $cells[]='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning').t3lib_BEfunc::referenceCount($foreign_table,$rec['uid'],' (There are %s reference(s) to this record!)')).')) {   '.$onClick.' } return false;').'">'.
                                                '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:delete',1).'" alt="" />'.
                                                '</a>';
                        }
                }
 
                        // If the record is edit-locked by another user, we will show a little warning sign:
-               if ($lockInfo=t3lib_BEfunc::isRecordLocked($table,$row['uid'])) {
+               if ($lockInfo=t3lib_BEfunc::isRecordLocked($foreign_table,$rec['uid'])) {
                        $cells[]='<a href="#" onclick="'.htmlspecialchars('alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;').'">'.
                                        '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
                                        '</a>';
@@ -489,7 +524,7 @@ class t3lib_TCEforms_inline {
 
                        // Compile items into a DIV-element:
                return '
-                                                                                       <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
+                                                                                       <!-- CONTROL PANEL: '.$foreign_table.':'.$rec['uid'].' -->
                                                                                        <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
        }
 
@@ -615,8 +650,35 @@ class t3lib_TCEforms_inline {
 
                return $itemsToSelect;
        }
+       
 
+       /**
+        * Creates a link/button to create new records
+        *
+        * @param       string          $objectPrefix: The "path" to the child record to create (e.g. '[parten_table][parent_uid][parent_field][child_table]')
+        * @param       string          $style: If a style should be added to the link (e.g. 'display: none;')
+        * @return      string          The HTML code for the new record link
+        */
+       function getNewRecordLink($objectPrefix, $conf = array()) {
+               if ($conf['inline']['inlineNewButtonStyle']) $style = ' style="'.$style.'"';
 
+               $onClick = "return inline.createNewRecord('$objectPrefix')";
+               $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.createnew',1);
+
+               if ($conf['appearance']['newRecordLinkAddTitle'])
+                       $tableTitle .= ' '.$GLOBALS['LANG']->sL($GLOBALS['TCA'][$conf['foreign_table']]['ctrl']['title'],1);
+
+               $out = '
+                               <div class="typo3-newRecordLink">
+                                       <a href="#" onClick="'.$onClick.'" class="inlineNewButton"'.$style.' title="'.$title.$tableTitle.'">'.
+                                       '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_el.gif','width="11" height="12"').' alt="'.$title.$tableTitle.'" />'.
+                                       $title.t3lib_div::fixed_lgd_cs($tableTitle, $this->fObj->titleLen).
+                                       '</a>
+                               </div>';
+               return $out;
+       }
+       
+       
        /**
         * Get the <script type="text/javascript" src="..."> tags of:
         * - prototype.js
@@ -633,6 +695,7 @@ class t3lib_TCEforms_inline {
 
                return implode("\n", $jsCode);
        }
+       
 
        /**
         * Add Sortable functionality using script.acolo.us "Sortable".
@@ -658,13 +721,11 @@ class t3lib_TCEforms_inline {
         * Handle AJAX calls to show a new inline-record of the given table.
         * Normally this method is never called from inside TYPO3. Always from outside by AJAX.
         *
-        * @param       mixed           $arguments: What to do and where to add, information from the calling browser.
-        * @param       string          $foreignUid: If set, the new record should be inserted after that one
+        * @param       string          $domObjectId: The calling object in hierarchy, that requested a new record.
+        * @param       string          $foreignUid: If set, the new record should be inserted after that one.
         * @return      string          A JSON string
         */
        function createNewRecord($domObjectId, $foreignUid = 0) {
-               global $TCA;
-
                        // parse the DOM identifier (string), add the levels to the structure stack (array) and load the TCA config
                $this->parseStructureString($domObjectId, true);
                        // the current table - for this table we should add/import records
@@ -746,46 +807,45 @@ class t3lib_TCEforms_inline {
 
 
        /**
-        * Creates recursively a JSON literal from a mulidimensional associative array.
-        * Uses Services_JSON (http://mike.teczno.com/JSON/doc/)
+        * Save the expanded/collapsed state of a child record in the BE_USER->uc.
         *
-        * @param       array           $jsonArray: The array (or part of) to be transformed to JSON
-        * @return      string          If $level>0: part of JSON literal; if $level==0: whole JSON literal wrapped with <script> tags
+        * @param       string          $domObjectId: The calling object in hierarchy, that requested a new record.
+        * @param       integer         $expanded: Whether this record is expanded or collapsed.
+        * @return      void
         */
-       function getJSON($jsonArray) {
-               if (!$GLOBALS['JSON']) {
-                       require_once('json.php');
-                       $GLOBALS['JSON'] = t3lib_div::makeInstance('Services_JSON');
+       function setExpandedCollapsedState($domObjectId, $expand, $collapse) {
+                       // parse the DOM identifier (string), add the levels to the structure stack (array), but don't load TCA config
+               $this->parseStructureString($domObjectId, false);
+                       // the current table - for this table we should add/import records
+               $current = $this->inlineStructure['unstable'];
+                       // the top parent table - this table embeds the current table
+               $top = $this->getStructureLevel(0);
+
+                       // only do some action if the top record and the current record were saved before
+               if (t3lib_div::testInt($top['uid'])) {
+                       $inlineView = unserialize($GLOBALS['BE_USER']->uc['inlineView']);
+                       $inlineViewCurrent =& $inlineView[$top['table']][$top['uid']];
+                       
+                       $expandUid = t3lib_div::trimExplode(',', $expand);
+                       $collapseUid = t3lib_div::trimExplode(',', $collapse);
+                       
+                               // set records to be expanded
+                       foreach ($expandUid as $uid) {
+                               $inlineViewCurrent[$current['table']][] = $uid;
+                       }
+                               // set records to be collapsed
+                       foreach ($collapseUid as $uid) {
+                               $inlineViewCurrent[$current['table']] = $this->removeFromArray($uid, $inlineViewCurrent[$current['table']]);
+                       }
+                       
+                               // save states back to database
+                       if (is_array($inlineViewCurrent[$current['table']])) {
+                               $GLOBALS['BE_USER']->uc['inlineView'] = serialize($inlineView);
+                               $GLOBALS['BE_USER']->writeUC();
+                       }
                }
-               return $GLOBALS['JSON']->encode($jsonArray);
-       }
-
-       /**
-        * Creates a link/button to create new records
-        *
-        * @param       string          $objectPrefix: The "path" to the child record to create (e.g. '[parten_table][parent_uid][parent_field][child_table]')
-        * @param       string          $style: If a style should be added to the link (e.g. 'display: none;')
-        * @return      string          The HTML code for the new record link
-        */
-       function getNewRecordLink($objectPrefix, $conf = array()) {
-               if ($conf['inline']['inlineNewButtonStyle']) $style = ' style="'.$style.'"';
-
-               $onClick = "return inline.createNewRecord('$objectPrefix')";
-               $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.createnew',1);
-
-               if ($conf['appearance']['newRecordLinkAddTitle'])
-                       $tableTitle .= ' '.$GLOBALS['LANG']->sL($GLOBALS['TCA'][$conf['foreign_table']]['ctrl']['title'],1);
-
-               $out = '
-                               <div class="typo3-newRecordLink">
-                                       <a href="#" onClick="'.$onClick.'" class="inlineNewButton"'.$style.' title="'.$title.$tableTitle.'">'.
-                                       '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_el.gif','width="11" height="12"').' alt="'.$title.$tableTitle.'" />'.
-                                       $title.t3lib_div::fixed_lgd_cs($tableTitle, $this->fObj->titleLen).
-                                       '</a>
-                               </div>';
-               return $out;
        }
-
+       
 
        /*******************************************************
         *
@@ -837,6 +897,8 @@ class t3lib_TCEforms_inline {
         * @return      array           Array of possible record items
         */
        function getPossibleRecords($table,$field,$row,$conf,$checkForConfField='foreign_selector') {
+                       // ctrl configuration from TCA:
+               $tcaTableCtrl = $GLOBALS['TCA'][$table]['ctrl'];
                        // Field configuration from TCA:
                $foreign_table = $conf['foreign_table'];
                $foreign_check = $conf[$checkForConfField];
@@ -856,7 +918,7 @@ class t3lib_TCEforms_inline {
                foreach($selItems as $tk => $p) {
 
                                // Checking languages and authMode:
-                       $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
+                       $languageDeny = $tcaTableCtrl['languageField'] && !strcmp($tcaTableCtrl['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
                        $authModeDeny = $config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$p[1],$config['authMode']);
                        if (in_array($p[1],$removeItems) || $languageDeny || $authModeDeny)     {
                                unset($selItems[$tk]);
@@ -983,11 +1045,17 @@ class t3lib_TCEforms_inline {
         */
        function updateStructureNames() {
                $current = $this->getStructureLevel(-1);
-               $lastItemName = $this->getStructureItemName($current);
-               $this->inlineNames = array(
-                       'form' => $this->prependFormFieldNames.$lastItemName,
-                       'object' => $this->prependNaming.'['.$this->inlineFirstPid.']'.$this->getStructurePath(),
-               );
+                       // if there are still more inline levels available
+               if ($current !== false) {
+                       $lastItemName = $this->getStructureItemName($current);
+                       $this->inlineNames = array(
+                               'form' => $this->prependFormFieldNames.$lastItemName,
+                               'object' => $this->prependNaming.'['.$this->inlineFirstPid.']'.$this->getStructurePath(),
+                       );
+                       // if there are no more inline levels available
+               } else {
+                       $this->inlineNames = array();
+               }
        }
 
 
@@ -998,9 +1066,12 @@ class t3lib_TCEforms_inline {
         * @return      string          The name/id of that level, to be used for HTML output
         */
        function getStructureItemName($levelData) {
-               return  '['.$levelData['table'].']' .
-                               '['.$levelData['uid'].']' .
-                               (isset($levelData['field']) ? '['.$levelData['field'].']' : '');
+               if (is_array($levelData)) {
+                       $name = '['.$levelData['table'].']' .
+                                       '['.$levelData['uid'].']' .
+                                       (isset($levelData['field']) ? '['.$levelData['field'].']' : '');
+               }
+               return $name;
        }
 
 
@@ -1055,8 +1126,6 @@ class t3lib_TCEforms_inline {
         * @return      void
         */
        function parseStructureString($string, $loadConfig = false) {
-               global $TCA;
-
                $unstable = array();
                $vector = array('table', 'uid', 'field');
                $pattern = '/^'.$this->prependNaming.'\[(.+?)\]\[(.+)\]$/';
@@ -1069,7 +1138,7 @@ class t3lib_TCEforms_inline {
                                                // load the TCA configuration of the table field and store it in the stack
                                        if ($loadConfig) {
                                                t3lib_div::loadTCA($unstable['table']);
-                                               $unstable['config'] = $TCA[$unstable['table']]['columns'][$unstable['field']]['config'];
+                                               $unstable['config'] = $GLOBALS['TCA'][$unstable['table']]['columns'][$unstable['field']]['config'];
                                        }
                                        $this->inlineStructure['stable'][] = $unstable;
                                        $unstable = array();
@@ -1121,8 +1190,6 @@ class t3lib_TCEforms_inline {
         * @return      boolean         Returns true is the user has access, or false if not
         */
        function checkAccess($cmd, $table, $theUid) {
-               global $BE_USER;
-
                        // Checking if the user has permissions? (Only working as a precaution, because the final permission check is always down in TCE. But it's good to notify the user on beforehand...)
                        // First, resetting flags.
                $hasAccess = 0;
@@ -1134,7 +1201,7 @@ class t3lib_TCEforms_inline {
                        if(!is_array($calcPRec)) {
                                return false;
                        }
-                       $CALC_PERMS = $BE_USER->calcPerms($calcPRec);   // Permissions for the parent page
+                       $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);        // Permissions for the parent page
                        if ($table=='pages')    {       // If pages:
                                $hasAccess = $CALC_PERMS&8 ? 1 : 0; // Are we allowed to create new subpages?
                        } else {
@@ -1145,26 +1212,26 @@ class t3lib_TCEforms_inline {
                        t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
                        if (is_array($calcPRec))        {
                                if ($table=='pages')    {       // If pages:
-                                       $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
+                                       $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);
                                        $hasAccess = $CALC_PERMS&2 ? 1 : 0;
                                } else {
-                                       $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));   // Fetching pid-record first.
+                                       $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));        // Fetching pid-record first.
                                        $hasAccess = $CALC_PERMS&16 ? 1 : 0;
                                }
 
                                        // Check internals regarding access:
                                if ($hasAccess) {
-                                       $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
+                                       $hasAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($table, $calcPRec);
                                }
                        }
                }
 
-               if(!$BE_USER->check('tables_modify', $table)) {
+               if(!$GLOBALS['BE_USER']->check('tables_modify', $table)) {
                        $hasAccess = 0;
                }
 
                if(!$hasAccess) {
-                       $deniedAccessReason = $BE_USER->errorMsg;
+                       $deniedAccessReason = $GLOBALS['BE_USER']->errorMsg;
                        if($deniedAccessReason) {
                                debug($deniedAccessReason);
                        }
@@ -1211,7 +1278,7 @@ class t3lib_TCEforms_inline {
         * @return      string          The wrapped HTML code
         */
        function wrapFormsSection($section, $styleAttrs = array(), $tableAttrs = array()) {
-               if (!$styleAttrs['margin-right']) $styleAttrs['margin-right'] = '5px';
+               if (!$styleAttrs['margin-right']) $styleAttrs['margin-right'] = $this->inlineStyles['margin-right'].'px';
 
                foreach ($styleAttrs as $key => $value) $style .= ($style?' ':'').$key.': '.htmlspecialchars($value).'; ';
                if ($style) $style = ' style="'.$style.'"';
@@ -1351,6 +1418,20 @@ class t3lib_TCEforms_inline {
                        ? true
                        : false;
        }
+       
+
+       /**
+        * Remove an element from an array.
+        *
+        * @param       mixed   $needle: The element to be removed.
+        * @param       array   $haystack: The array the element should be removed from.
+        * @return      mixed   $strict: Search elements strictly.
+        */
+       function removeFromArray($needle, $haystack, $strict=null) {
+               $pos = array_search($needle, $haystack, $strict);
+               if ($pos !== false) unset($haystack[$pos]);
+               return $haystack;
+       }
 
 
        /**
@@ -1400,8 +1481,10 @@ class t3lib_TCEforms_inline {
                                                        ),
                                                ),
                                                1 => array(
-                                                       'foreign_table' => $config['foreign_table'],
-                                                       'foreign_selector' => $config['foreign_field']
+                                                       '%AND' => array(
+                                                               'foreign_table' => $config['foreign_table'],
+                                                               'foreign_selector' => $config['foreign_field'],
+                                                       ),
                                                ),
                                        ),
                                ),
@@ -1425,5 +1508,69 @@ class t3lib_TCEforms_inline {
 
                return $skipThisField;
        }
+       
+       
+       /**
+        * Creates recursively a JSON literal from a mulidimensional associative array.
+        * Uses Services_JSON (http://mike.teczno.com/JSON/doc/)
+        *
+        * @param       array           $jsonArray: The array (or part of) to be transformed to JSON
+        * @return      string          If $level>0: part of JSON literal; if $level==0: whole JSON literal wrapped with <script> tags
+        */
+       function getJSON($jsonArray) {
+               if (!$GLOBALS['JSON']) {
+                       require_once('json.php');
+                       $GLOBALS['JSON'] = t3lib_div::makeInstance('Services_JSON');
+               }
+               return $GLOBALS['JSON']->encode($jsonArray);
+       }
+
+       
+       /**
+        * Checks if a uid of a child table is in the inline view settings.
+        *
+        * @param       string          $table: Name of the child table
+        * @param       integer         $uid: uid of the the child record
+        * @return      boolean         true=expand, false=collapse
+        */
+       function getExpandedCollapsedState($table, $uid) {
+               if (is_array($this->inlineView) && is_array($this->inlineView[$table])) {
+                       if (in_array($uid, $this->inlineView[$table]) !== false) return true;
+               }
+               return false;
+       }
+       
+       
+       /**
+        * Update expanded/collapsed states on new inline records if any.
+        *
+        * @param       array           $uc: The uc array to be processed and saved (by reference)
+        * @param       object          $tce: Instance of TCEmain that saved data before (by reference)
+        * @return      void
+        */
+       function updateInlineView(&$uc, &$tce) {
+               if (is_array($uc) && $uc['inlineView']) {
+                       $inlineView = unserialize($GLOBALS['BE_USER']->uc['inlineView']);
+                       
+                       foreach ($uc['inlineView'] as $topTable => $topRecords) {
+                               foreach ($topRecords as $topUid => $childElements) {
+                                       foreach ($childElements as $childTable => $childRecords) {
+                                               $uids = array_keys($tce->substNEWwithIDs_table, $childTable);
+                                               if (count($uids)) {
+                                                       foreach ($childRecords as $childUid => $state) {
+                                                               if ($state && in_array($childUid, $uids)) {
+                                                                       $newChildUid = $tce->substNEWwithIDs[$childUid];
+                                                                       $inlineView[$topTable][$topUid][$childTable][$newChildUid] = 1;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       
+                       $GLOBALS['BE_USER']->uc['inlineView'] = serialize($inlineView);
+                       $GLOBALS['BE_USER']->writeUC();
+               }
+       }
  }
 ?>
\ No newline at end of file
index 7abd27f..a3fdc40 100755 (executable)
@@ -277,6 +277,7 @@ class t3lib_TCEmain {
        var $autoVersionIdMap = Array();                        // Contains mapping of auto-versionized records.
        var $substNEWwithIDs = Array();                         // When new elements are created, this array contains a map between their "NEW..." string IDs and the eventual UID they got when stored in database
        var $substNEWwithIDs_table = Array();           // Like $substNEWwithIDs, but where each old "NEW..." id is mapped to the table it was from.
+       var $newRelatedIDs = Array();                           // Holds the tables and there the ids of newly created child records from IRRE
        var $copyMappingArray_merged = Array();         // This array is the sum of all copying operations in this class. May be READ from outside, thus partly public.
        var $copiedFileMap = Array();                           // A map between input file name and final destination for files being attached to records.
        var     $errorLog = Array();                                    // Errors are collected in this variable.
@@ -330,7 +331,8 @@ class t3lib_TCEmain {
        var $copyMappingArray = Array();                        // Used by the copy action to track the ids of new pages so subpages are correctly inserted! THIS is internally cleared for each executed copy operation! DO NOT USE THIS FROM OUTSIDE! Read from copyMappingArray_merged instead which is accumulating this information.
        var $remapStack = array();                                      // array used for remapping uids and values at the end of process_datamap
        var $updateRefIndexStack = array();                     // array used for additional calls to $this->updateRefIndex
-
+       var $callFromImpExp = false;                            // tells, that this TCEmain was called from tx_impext - this variable is set by tx_impexp
+       
                // Various
        var $fileFunc;                                                          // For "singleTon" file-manipulation object
        var $checkValue_currentRecord=array();          // Set to "currentRecord" during checking of values.
@@ -839,7 +841,10 @@ class t3lib_TCEmain        {
                                if(is_array($valueArray)) {
                                        foreach($valueArray as $key => $value) {
                                                if(strpos($value, 'NEW') !== false) {
+                                                               // fetch the proper uid as integer for the NEW...-ID
                                                        $valueArray[$key] = $this->substNEWwithIDs[$value];
+                                                               // set a hint that this was a new child record
+                                                       $this->newRelatedIDs[$table][] = $valueArray[$key];
                                                }
                                        }
                                        $remapAction['args'][$remapAction['pos']['valueArray']] = $valueArray;
@@ -2012,8 +2017,10 @@ class t3lib_TCEmain      {
                        $valueArray = $dbAnalysis->countItems();
                } elseif ($type == 'inline') {
                        if ($tcaFieldConf['foreign_field']) {
-                                       // update sorting
-                               $dbAnalysis->writeForeignField($tcaFieldConf, $id);
+                                       // if the record was imported, sorting was also imported, so skip this
+                               $skipSorting = $this->callFromImpExp ? true : false;
+                                       // update record in intermediate table (sorting & pointer uid to parent record)
+                               $dbAnalysis->writeForeignField($tcaFieldConf, $id, 0, $skipSorting);
                                $valueArray = $dbAnalysis->countItems();
                        } else {
                                $valueArray = $dbAnalysis->getValueArray($prep);
index 2c8bcb4..e444919 100644 (file)
@@ -46,28 +46,61 @@ var inline = {
        },
        
        expandCollapseRecord: function(objectId, expandSingle) {
+               var currentUid = this.parseFormElementName('none', objectId, 1);
+               var objectPrefix = this.parseFormElementName('full', objectId, 0, 1);
+               
+               var currentState = '';
+               var collapse = new Array();
+               var expand = new Array();
+
                        // if only a single record should be visibly for that set of records
                        // and the record clicked itself is no visible, collapse all others
-               if (expandSingle && !Element.visible(objectId+'_fields')) this.collapseAllRecords(objectId);
+               if (expandSingle && !Element.visible(objectId+'_fields'))
+                       collapse = this.collapseAllRecords(objectId, objectPrefix, currentUid);
+
                Element.toggle(objectId+'_fields');
+               currentState = Element.visible(objectId+'_fields') ? 1 : 0
+               
+               if (this.isNewRecord(objectId))
+                       this.updateExpandedCollapsedStateLocally(objectId, currentState);
+               else if (currentState)
+                       expand.push(currentUid);
+               else if (!currentState)
+                       collapse.push(currentUid);
+
+               this.setExpandedCollapsedState(objectId, expand.join(','), collapse.join(','));
+               
                return false;
        },
-       
-       collapseAllRecords: function(objectId) {
+
+       collapseAllRecords: function(objectId, objectPrefix, callingUid) {
                        // get the form field, where all records are stored
                var objectName = this.prependFormFieldNames+this.parseFormElementName('parts', objectId, 3, 2);
                var formObj = document.getElementsByName(objectName);
+               var collapse = [];
 
                if (formObj.length) {
                                // the uid of the calling object (last part in objectId)
-                       var callingUid = this.parseFormElementName('none', objectId, 1);
-                       var objectPrefix = this.parseFormElementName('full', objectId, 0 , 1);
+                       var recObjectId = '';
 
                        var records = formObj[0].value.split(',');
                        for (var i=0; i<records.length; i++) {
-                               if (records[i] != callingUid) Element.hide(objectPrefix+'['+records[i]+']_fields');
+                               recObjectId = objectPrefix+'['+records[i]+']';
+                               if (records[i] != callingUid && Element.visible(recObjectId+'_fields')) {
+                                       Element.hide(recObjectId+'_fields');
+                                       if (this.isNewRecord(recObjectId)) this.updateExpandedCollapsedStateLocally(recObjectId, 0);
+                                       else collapse.push(records[i]);
+                               }
                        }
                }
+               
+               return collapse;
+       },
+       
+       updateExpandedCollapsedStateLocally: function(objectId, value) {
+               var ucName = 'uc'+this.parseFormElementName('parts', objectId, 3, 2);
+               var ucFormObj = document.getElementsByName(ucName);
+               if (ucFormObj.length) ucFormObj[0].value = value;
        },
        
        createNewRecord: function(objectId,prevRecordUid) {
@@ -76,6 +109,11 @@ var inline = {
                return false;
        },
 
+       setExpandedCollapsedState: function(objectId, expand, collapse) {
+               // alert(objectId+': '+expand+', '+collapse);
+               this.makeAjaxCall('setExpandedCollapsedState', objectId, expand, collapse);
+       },
+       
        makeAjaxCall: function() {
                if (arguments.length > 1) {
                        var params = '';
@@ -403,7 +441,7 @@ var inline = {
                if (this.data.unique && this.data.unique[objectPrefix]) this.revertUnique(objectPrefix, elName, recordUid);
 
                        // if the record is new and was never saved before, just remove it from DOM
-               if ($(objectId+'_div') && $(objectId+'_div').hasClassName('inlineIsNewRecord')) {
+               if (this.isNewRecord(objectId)) {
                        new Effect.Fade(objectId+'_div', { afterFinish: function() { Element.remove(objectId+'_div'); } });
                        // if the record already exists in storage, mark it to be deleted on clicking the save button
                } else {
@@ -570,6 +608,12 @@ var inline = {
                var optOut = { duration:0.5, transition:Effect.Transitions.linear, from:1.00, to:0.50 };
                optOut.afterFinish = function() { new Effect.Opacity(objectId, optIn); };
                new Effect.Opacity(objectId, optOut);
+       },
+       
+       isNewRecord: function(objectId) {
+               return $(objectId+'_div') && $(objectId+'_div').hasClassName('inlineIsNewRecord')
+                       ? true
+                       : false;
        }
 }
 
index 24297ac..1430c22 100755 (executable)
@@ -120,7 +120,8 @@ class SC_alt_doc {
        var $disableRTE;                // GPvar (for processing only) : If set, the rich text editor is disabled in the forms.
        var $returnNewPageId;   // GPvar (for processing only) : Boolean: If set, then the GET var "&id=" will be added to the retUrl string so that the NEW id of something is returned to the script calling the form.
        var $vC;                                // GPvar (for processing only) : Verification code, internal stuff.
-
+       var $uc;                                // GPvar : update BE_USER->uc
+       
        var $popViewId;                 // GPvar (module) : ID for displaying the page in the frontend (used for SAVE/VIEW operations)
        var $popViewId_addParams;       // GPvar (module) : Additional GET vars for the link, eg. "&L=xxx"
        var $viewUrl;                   // GPvar (module) : Alternative URL for viewing the frontend pages.
@@ -193,6 +194,7 @@ class SC_alt_doc {
                $this->doSave = t3lib_div::_GP('doSave');
                $this->returnEditConf = t3lib_div::_GP('returnEditConf');
                $this->localizationMode = t3lib_div::_GP('localizationMode');
+               $this->uc = t3lib_div::_GP('uc');
 
 
                        // Setting override values as default if defVals does not exist.
@@ -302,17 +304,22 @@ class SC_alt_doc {
 
                                // If there was saved any new items, load them:
                        if (count($tce->substNEWwithIDs_table)) {
+                                       // save the expanded/collapsed states for new inline records, if any
+                               t3lib_TCEforms_inline::updateInlineView($this->uc, $tce);
 
                                foreach($this->editconf as $tableName => $tableCmds) {
                                        $keys = array_keys($tce->substNEWwithIDs_table, $tableName);
                                        if(count($keys) > 0) {
                                                foreach($keys as $key) {
                                                        $editId = $tce->substNEWwithIDs[$key];
-                                                               // translate new id to the workspace version:
-                                                       if ($versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $nTable, $editId,'uid'))    {
-                                                               $editId = $versionRec['uid'];
+                                                               // check if the $editId isn't a child record of an IRRE action
+                                                       if (!(is_array($tce->newRelatedIDs[$tableName]) && in_array($editId, $tce->newRelatedIDs[$tableName]))) {
+                                                                       // translate new id to the workspace version:
+                                                               if ($versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $nTable, $editId,'uid'))    {
+                                                                       $editId = $versionRec['uid'];
+                                                               }
+                                                               $newEditConf[$tableName][$editId] = 'edit';
                                                        }
-                                                       $newEditConf[$tableName][$editId] = 'edit';
        
                                                                // Traverse all new records and forge the content of ->editconf so we can continue to EDIT these records!
                                                        if ($tableName=='pages' && $this->retUrl!='dummy.php' && $this->returnNewPageId)        {
index 44bb611..ba9d8f8 100644 (file)
@@ -116,7 +116,7 @@ class SC_alt_doc_ajax {
         * @return      void
         */
        function main() {
-               header('Expires: Fri, 27 Nov 1981 09:43:00 GMT');
+               header('Expires: Fri, 27 Nov 1981 09:04:00 GMT');
                header('Last-Modified: '.gmdate("D, d M Y H:i:s").' GMT');
                header('Cache-Control: no-cache, must-revalidate');
                header('Pragma: no-cache');
@@ -128,7 +128,7 @@ class SC_alt_doc_ajax {
                        $method = array_shift($this->ajax);
 
                                // Security check
-                       if(!in_array($method, array('createNewRecord'))) return false;
+                       if(!in_array($method, array('createNewRecord', 'setExpandedCollapsedState'))) return false;
 
                        $this->content = call_user_func_array(
                                array(&$this->tceforms->inline, $method),
index 8ebb0ef..a68e309 100644 (file)
@@ -355,6 +355,8 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                global $BE_USER,$LANG, $TYPO3_DB, $TYPO3_CONF_VARS;
 
                $this->TCEform = $pObj;
+               $inline =& $this->TCEform->inline;
+               
                $LANG->includeLLFile('EXT:' . $this->ID . '/locallang.xml');
                $this->client = $this->clientInfo();
                $this->typoVersion = t3lib_div::int_from_ver(TYPO3_version);
@@ -428,11 +430,11 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                                        $tableB = 'static_languages';
                                        $languagesUidsList = $this->contentLanguageUid;
                                        $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
-                                       $table = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
+                                       $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
                                        $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
                                        $whereClause .= t3lib_BEfunc::BEenableFields($tableA);
                                        $whereClause .= t3lib_BEfunc::deleteClause($tableA);
-                                       $res = $TYPO3_DB->exec_SELECTquery($selectFields, $table, $whereClause);
+                                       $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                                        while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                                                $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']).(trim($languageRow['lg_country_iso_2'])?'_'.trim($languageRow['lg_country_iso_2']):''));
                                                $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
@@ -440,9 +442,9 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                                } else {
                                        $this->contentISOLanguage = trim($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['defaultDictionary']) ? trim($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['defaultDictionary']) : 'en';
                                        $selectFields = 'lg_iso_2, lg_typo3';
-                                       $table = 'static_languages';
-                                       $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $table);
-                                       $res = $TYPO3_DB->exec_SELECTquery($selectFields, $table, $whereClause);
+                                       $tableAB = 'static_languages';
+                                       $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
+                                       $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                                        while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                                                $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                                        }
@@ -519,6 +521,7 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                        $RTEWidth = isset($BE_USER->userTS['options.']['RTESmallWidth']) ? $BE_USER->userTS['options.']['RTESmallWidth'] : '530';
                        $RTEHeight = isset($BE_USER->userTS['options.']['RTESmallHeight']) ? $BE_USER->userTS['options.']['RTESmallHeight'] : '380';
                        $RTEWidth  = $RTEWidth + ($pObj->docLarge ? (isset($BE_USER->userTS['options.']['RTELargeWidthIncrement']) ? $BE_USER->userTS['options.']['RTELargeWidthIncrement'] : '150') : 0);
+                       $RTEWidth -= ($inline->inlineCount > 0 ? ($inline->inlineCount+1)*$inline->inlineStyles['margin-right'] : 0);
                        $RTEHeight = $RTEHeight + ($pObj->docLarge ?  (isset($BE_USER->userTS['options.']['RTELargeHeightIncrement']) ? $BE_USER->userTS['options.']['RTELargeHeightIncrement'] : 0) : 0);
                        $editorWrapWidth = $RTEWidth . 'px';
                        $editorWrapHeight = $RTEHeight . 'px';
@@ -603,7 +606,7 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                        }
 
                                // Register RTE in JS:
-                       $pObj->additionalJS_post[] = $this->registerRTEinJS($pObj->RTEcounter);
+                       $pObj->additionalJS_post[] = $this->registerRTEinJS($pObj->RTEcounter, $table, $row['uid'], $field);
 
                                // Set the save option for the RTE:
                        $pObj->additionalJS_submit[] = $this->setSaveRTE($pObj->RTEcounter, $pObj->formName, htmlspecialchars($PA['itemFormElName']));
@@ -892,12 +895,22 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
        
        /**
         * Return the JS-Code for Register the RTE in JS
+        * 
+        * @param       integer         $number: The index number of the RTE.
+        * @param       string          $table: The table that includes this RTE (optional, necessary for IRRE).
+        * @param       string          $uid: The uid of that table that includes this RTE (optional, necessary for IRRE).
+        * @param       string          $field: The field of that record that includes this RTE (optional).
         *
         * @return string               the JS-Code for Register the RTE in JS
         */
        
-       function registerRTEinJS($number) {
+       function registerRTEinJS($number, $table='', $uid='', $field='') {
                global $TSFE, $TYPO3_CONF_VARS;
+
+                       // if this RTE is shown inline of an IRRE record, the JS functions need to know about that
+               if ($this->TCEform->inline->inlineNames['object']) {
+                       $tceformsInlineObject = $this->TCEform->inline->inlineNames['object'].'['.$table.']['.$uid.']_fields';
+               }
                
                $registerRTEinJSString = (!is_object($TSFE) ? '' : '
                        ' . '/*<![CDATA[*/') . '
@@ -914,7 +927,9 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                        RTEarea['.$number.']["statusBar"] = ' . (trim($this->thisConfig['showStatusBar'])?'true':'false') . ';
                        RTEarea['.$number.']["showTagFreeClasses"] = ' . (trim($this->thisConfig['showTagFreeClasses'])?'true':'false') . ';
                        RTEarea['.$number.']["useHTTPS"] = ' . ((trim(stristr($this->siteURL, 'https')) || $this->thisConfig['forceHTTPS'])?'true':'false') . ';
-                       RTEarea['.$number.']["enableMozillaExtension"] = ' . (($this->client['BROWSER'] == 'gecko' && $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableMozillaExtension'])?'true':'false') . ';';
+                       RTEarea['.$number.']["enableMozillaExtension"] = ' . (($this->client['BROWSER'] == 'gecko' && $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableMozillaExtension'])?'true':'false') . ';
+                       RTEarea['.$number.']["tceformsInlineObject"] = "' . $tceformsInlineObject . '";
+                       RTEarea['.$number.']["tceformsDynTabs"] = "' . $this->TCEform->getDynTabLevelState('-DIV') . '";';
                
                        // The following properties apply only to the backend
                if (!is_object($TSFE)) {
index e464ebe..b2abf10 100644 (file)
@@ -1,2 +1,180 @@
-if(typeof(_editor_url)=="string"){_editor_url=_editor_url.replace(/\x2f*$/,'/');}else{alert("WARNING: _editor_url is not set!");var _editor_url='';};if(typeof(_editor_skin)=="string")_editor_skin=_editor_skin.replace(/\x2f*$/,'/');else var _editor_skin=_editor_url+"skins/default/";if(typeof(_editor_CSS)!="string")var _editor_CSS=_editor_url+"skins/default/htmlarea.css";if(typeof(_editor_edited_content_CSS)!="string")var _editor_edited_content_CSS=_editor_skin+"htmlarea-edited-content.css";if(typeof(_editor_lang)=="string")_editor_lang=_editor_lang?_editor_lang.toLowerCase():"en";var HTMLArea=function(textarea,config){if(HTMLArea.checkSupportedBrowser()){if(typeof(config)=="undefined")this.config=new HTMLArea.Config();else this.config=config;this._htmlArea=null;this._textArea=textarea;this._editMode="wysiwyg";this.plugins={};this._timerToolbar=null;this._undoQueue=new Array();this._undoPos=-1;this._customUndo=true;this.doctype='';this.eventHandlers={};}};HTMLArea.agt=navigator.userAgent.toLowerCase();HTMLArea.is_opera=(HTMLArea.agt.indexOf("opera")!=-1);HTMLArea.is_ie=(HTMLArea.agt.indexOf("msie")!=-1)&&!HTMLArea.is_opera;HTMLArea.is_safari=(HTMLArea.agt.indexOf("webkit")!=-1);HTMLArea.is_gecko=(navigator.product=="Gecko")||HTMLArea.is_opera;HTMLArea.is_wamcom=(HTMLArea.agt.indexOf("wamcom")!=-1)||(HTMLArea.is_gecko&&(HTMLArea.agt.indexOf("1.3")!=-1));HTMLArea._debugMode=false;if(typeof(_editor_debug_mode)!="undefined")HTMLArea._debugMode=_editor_debug_mode;HTMLArea._appendToLog=function(str){if(HTMLArea._debugMode){var log=document.getElementById("HTMLAreaLog");if(log){log.appendChild(document.createTextNode(str));log.appendChild(document.createElement("br"));}}};HTMLArea._compressedScripts=false;if(typeof(_editor_compressed_scripts)!="undefined")HTMLArea._compressedScripts=_editor_compressed_scripts;HTMLArea.I18N=HTMLArea_langArray;HTMLArea.is_loaded=false;HTMLArea.onload=function(){HTMLArea.is_loaded=true;HTMLArea._appendToLog("All scripts successfully loaded.");};HTMLArea.loadTimer;HTMLArea._scripts=[];HTMLArea._scriptLoaded=[];HTMLArea._request=[];HTMLArea.loadScript=function(url,plugin){if(plugin)url=_editor_url+"/plugins/"+plugin+'/'+url;if(HTMLArea.is_opera)url=_typo3_host_url+url;if(HTMLArea._compressedScripts&&url.indexOf("compressed")==-1)url=url.replace(/\.js$/gi,"-compressed.js");HTMLArea._scripts.push(url);};HTMLArea.loadScript(RTEarea[0]["popupwin"]?RTEarea[0]["popupwin"]:_editor_url+"popupwin.js");if(HTMLArea.is_gecko)HTMLArea.loadScript(RTEarea[0]["htmlarea-gecko"]?RTEarea[0]["htmlarea-gecko"]:_editor_url+"htmlarea-gecko.js");if(HTMLArea.is_ie)HTMLArea.loadScript(RTEarea[0]["htmlarea-ie"]?RTEarea[0]["htmlarea-ie"]:_editor_url+"htmlarea-ie.js");HTMLArea.MSXML_XMLHTTP_PROGIDS=new Array("Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP");HTMLArea.XMLHTTPResponseHandler=function(i){return(function(){var url=HTMLArea._scripts[i];if(HTMLArea._request[i].readyState!=4)return;if(HTMLArea._request[i].status==200){try{eval(HTMLArea._request[i].responseText);HTMLArea._scriptLoaded[i]=true;i=null;}catch(e){HTMLArea._appendToLog("ERROR [HTMLArea::getScript]: Unable to get script "+url+": "+e);}}else{HTMLArea._appendToLog("ERROR [HTMLArea::getScript]: Unable to get "+url+" . Server reported "+HTMLArea._request[i].status);}});};HTMLArea._getScript=function(i,asynchronous,url){if(typeof(url)=="undefined")var url=HTMLArea._scripts[i];if(typeof(asynchronous)=="undefined")var asynchronous=true;if(window.XMLHttpRequest)HTMLArea._request[i]=new XMLHttpRequest();else if(window.ActiveXObject){var success=false;for(var k=0;k<HTMLArea.MSXML_XMLHTTP_PROGIDS.length&&!success;k++){try{HTMLArea._request[i]=new ActiveXObject(HTMLArea.MSXML_XMLHTTP_PROGIDS[k]);success=true;}catch(e){}};if(!success)return false;};var request=HTMLArea._request[i];if(request){request.open("GET",url,asynchronous);if(asynchronous)request.onreadystatechange=HTMLArea.XMLHTTPResponseHandler(i);if(window.XMLHttpRequest)request.send(null);else if(window.ActiveXObject)request.send();if(!asynchronous){if(request.status==200)return request.responseText;else return '';};return true;}else{return false;}};HTMLArea.checkInitialLoad=function(){var scriptsLoaded=true;for(var i=HTMLArea._scripts.length;--i>=0;){scriptsLoaded=scriptsLoaded&&HTMLArea._scriptLoaded[i];};if(HTMLArea.loadTimer)window.clearTimeout(HTMLArea.loadTimer);if(scriptsLoaded){HTMLArea.is_loaded=true;HTMLArea._appendToLog("[HTMLArea::init]: All scripts successfully loaded.");HTMLArea._appendToLog("[HTMLArea::init]: Editor url set to: "+_editor_url);HTMLArea._appendToLog("[HTMLArea::init]: Editor skin CSS set to: "+_editor_CSS);HTMLArea._appendToLog("[HTMLArea::init]: Editor content skin CSS set to: "+_editor_edited_content_CSS);if(window.ActiveXObject){for(var i=HTMLArea._scripts.length;--i>=0;){HTMLArea._request[i].onreadystatechange=new Function();HTMLArea._request[i]=null;}}}else{HTMLArea.loadTimer=window.setTimeout("HTMLArea.checkInitialLoad();",200);return false;}};HTMLArea.init=function(){HTMLArea._eventCache=HTMLArea._eventCacheConstructor();if(window.XMLHttpRequest||window.ActiveXObject){try{var success=true;for(var i=HTMLArea._scripts.length;--i>=0&&success;)success=success&&HTMLArea._getScript(i);}catch(e){HTMLArea._appendToLog("ERROR [HTMLArea::init]: Unable to use XMLHttpRequest: "+e);};if(success){HTMLArea.checkInitialLoad();}else{if(HTMLArea.is_ie)window.setTimeout('if (window.document.getElementById("pleasewait1")) { window.document.getElementById("pleasewait1").innerHTML = HTMLArea.I18N.msg["ActiveX-required"]; } else { alert(HTMLArea.I18N.msg["ActiveX-required"]); };',200);}}else{if(HTMLArea.is_ie)alert(HTMLArea.I18N.msg["ActiveX-required"]);}};HTMLArea.RE_tagName=/(<\/|<)\s*([^\t\n>]+)/ig;HTMLArea.RE_doctype=/(<!doctype((.|\n)*?)>)\n?/i;HTMLArea.RE_head=/<head>((.|\n)*?)<\/head>/i;HTMLArea.RE_body=/<body>((.|\n)*?)<\/body>/i;HTMLArea.Reg_body=new RegExp("<\/?(body)[^>]*>","gi");HTMLArea.Reg_entities=new RegExp("&amp;([0-9]+);","gi");HTMLArea.reservedClassNames=/htmlarea/;HTMLArea.RE_email=/([0-9a-z]+([a-z0-9_-]*[0-9a-z])*){1}(\.[0-9a-z]+([a-z0-9_-]*[0-9a-z])*)*@([0-9a-z]+([a-z0-9_-]*[0-9a-z])*\.)+[a-z]{2,9}/i;HTMLArea.RE_url=/(https?:\/\/)?(([a-z0-9_]+:[a-z0-9_]+@)?[a-z0-9_-]{2,}(\.[a-z0-9_-]{2,})+\.[a-z]{2,5}(:[0-9]+)?(\/\S+)*)/i;HTMLArea.Config=function(){this.version="3.0";this.width="auto";this.height="auto";this.statusBar=true;this.undoSteps=20;this.undoTimeout=500;this.sizeIncludesToolbar=true;this.fullPage=false;this.useHTTPS=false;this.useCSS=false;this.enableMozillaExtension=true;this.disableEnterParagraphs=false;this.removeTrailingBR=false;this.editedContentStyle=_editor_edited_content_CSS;this.pageStyle="";this.cleanWordOnPaste=true;this.makeLinkShowsTarget=true;this.htmlRemoveTags=null;this.htmlRemoveTagsAndContents=null;this.htmlRemoveComments=false;this.customTags=null;this.baseURL=document.baseURI||document.URL;if(this.baseURL&&this.baseURL.match(/(.*)\/([^\/]+)/))this.baseURL=RegExp.$1+"/";this.imgURL="images/";this.popupURL="popups/";this.btnList={Bold:["Bold","ed_format_bold",false,function(editor){editor.execCommand("Bold");}],Italic:["Italic","ed_format_italic",false,function(editor){editor.execCommand("Italic");}],Underline:["Underline","ed_format_underline",false,function(editor){editor.execCommand("Underline");}],StrikeThrough:["Strikethrough","ed_format_strike",false,function(editor){editor.execCommand("StrikeThrough");}],Subscript:["Subscript","ed_format_sub",false,function(editor){editor.execCommand("Subscript");}],Superscript:["Superscript","ed_format_sup",false,function(editor){editor.execCommand("Superscript");}],JustifyLeft:["Justify Left","ed_align_left.gif",false,function(editor){editor.execCommand("JustifyLeft");}],JustifyCenter:["Justify Center","ed_align_center.gif",false,function(editor){editor.execCommand("JustifyCenter");}],JustifyRight:["Justify Right","ed_align_right.gif",false,function(editor){editor.execCommand("JustifyRight");}],JustifyFull:["Justify Full","ed_align_justify.gif",false,function(editor){editor.execCommand("JustifyFull");}],InsertOrderedList:["Ordered List","ed_list_num.gif",false,function(editor){editor.execCommand("InsertOrderedList");}],InsertUnorderedList:["Bulleted List","ed_list_bullet",false,function(editor){editor.execCommand("InsertUnorderedList");}],Outdent:["Decrease Indent","ed_indent_less.gif",false,function(editor){editor.execCommand("Outdent");}],Indent:["Increase Indent","ed_indent_more.gif",false,function(editor){editor.execCommand("Indent");}],ForeColor:["Font Color","ed_color_fg.gif",false,function(editor){editor.execCommand("ForeColor");}],HiliteColor:["Background Color","ed_color_bg.gif",false,function(editor){editor.execCommand("HiliteColor");}],InsertHorizontalRule:["Horizontal Rule","ed_hr.gif",false,function(editor){editor.execCommand("InsertHorizontalRule");}],CreateLink:["Insert Web Link","ed_link.gif",false,function(editor){editor.execCommand("CreateLink",true);},"a",false,true],InsertImage:["Insert/Modify Image","ed_image.gif",false,function(editor){editor.execCommand("InsertImage");}],InsertTable:["Insert Table","insert_table.gif",false,function(editor){editor.execCommand("InsertTable");}],HtmlMode:["Toggle HTML Source","ed_html.gif",true,function(editor){editor.execCommand("HtmlMode");}],SelectAll:["SelectAll","",true,function(editor){editor.execCommand("SelectAll");},null,true,false],SplitBlock:["Toggle Container Block","ed_splitblock.gif",false,function(editor){editor.execCommand("SplitBlock");}],About:["About this editor","ed_about.gif",true,function(editor){editor.execCommand("About");}],Undo:["Undoes your last action","ed_undo.gif",false,function(editor){editor.execCommand("Undo");}],Redo:["Redoes your last action","ed_redo.gif",false,function(editor){editor.execCommand("Redo");}],Cut:["Cut selection","ed_cut.gif",false,function(editor,command,obj){editor.execCommand("Cut");}],Copy:["Copy selection","ed_copy.gif",false,function(editor,command,obj){editor.execCommand("Copy");}],Paste:["Paste from clipboard","ed_paste.gif",false,function(editor,command,obj){editor.execCommand("Paste");}],SelectAll:["SelectAll","",true,function(editor){editor.execCommand("SelectAll");},null,true,false],LeftToRight:["Direction left to right","ed_left_to_right.gif",false,function(editor){editor.execCommand("LeftToRight");}],RightToLeft:["Direction right to left","ed_right_to_left.gif",false,function(editor){editor.execCommand("RightToLeft");}]};this.hotKeyList={a:"SelectAll",b:"Bold",i:"Italic",u:"Underline",s:"StrikeThrough",l:"JustifyLeft",e:"JustifyCenter",r:"JustifyRight",j:"JustifyFull",n:"FormatBlock",v:"Paste",0:"CleanWord",z:"Undo",y:"Redo"};for(var i in this.btnList){var btn=this.btnList[i];if(typeof(HTMLArea.I18N.tooltips[i.toLowerCase()])!="undefined")btn[0]=HTMLArea.I18N.tooltips[i.toLowerCase()];if(typeof(btn[1])=="string")btn[1]=_editor_skin+this.imgURL+btn[1];else btn[1][0]=_editor_skin+this.imgURL+btn[1][0];}this.customSelects={};};HTMLArea.Config.prototype.registerButton=function(id,tooltip,image,textMode,action,context,hide,selection){var the_id;switch(typeof(id)){case "string":the_id=id;break;case "object":the_id=id.id;break;default:HTMLArea._appendToLog("ERROR [HTMLArea.Config::registerButton]: invalid arguments");return false;}if(typeof(this.customSelects[the_id])!="undefined")HTMLArea._appendToLog("WARNING [HTMLArea.Config::registerButton]: A dropdown with the same ID "+id+" already exists.");if(typeof(this.btnList[the_id])!="undefined")HTMLArea._appendToLog("WARNING [HTMLArea.Config::registerButton]: A button with the same ID "+id+" already exists.");switch(typeof(id)){case "string":if(typeof(hide)=="undefined")var hide=false;if(typeof(selection)=="undefined")var selection=false;this.btnList[id]=[tooltip,image,textMode,action,context,hide,selection];break;case "object":if(typeof(id.hide)=="undefined")id.hide=false;if(typeof(id.selection)=="undefined")id.selection=false;this.btnList[id.id]=[id.tooltip,id.image,id.textMode,id.action,id.context,id.hide,id.selection];break;}};HTMLArea.Config.prototype.registerDropdown=function(object){if(typeof(this.customSelects[object.id])!="undefined")HTMLArea._appendToLog("WARNING [HTMLArea.Config::registerDropdown]: A dropdown with the same ID "+object.id+" already exists.");if(typeof(this.btnList[object.id])!="undefined")HTMLArea._appendToLog("WARNING [HTMLArea.Config::registerDropdown]: A button with the same ID "+object.id+" already exists.");this.customSelects[object.id]=object;};HTMLArea.setButtonStatus=function(id,newval){var oldval=this[id];var el=document.getElementById(this.elementId);if(oldval!=newval){switch(id){case "enabled":if(newval){if(!HTMLArea.is_wamcom){HTMLArea._removeClass(el,"buttonDisabled");HTMLArea._removeClass(el.parentNode,"buttonDisabled");}el.disabled=false;}else{if(!HTMLArea.is_wamcom){HTMLArea._addClass(el,"buttonDisabled");HTMLArea._addClass(el.parentNode,"buttonDisabled");}el.disabled=true;}break;case "active":if(newval){HTMLArea._addClass(el,"buttonPressed");HTMLArea._addClass(el.parentNode,"buttonPressed");}else{HTMLArea._removeClass(el,"buttonPressed");HTMLArea._removeClass(el.parentNode,"buttonPressed");}break;}this[id]=newval;}};HTMLArea.newLine=function(toolbar){tb_line=document.createElement("ul");tb_line.className="tb-line";toolbar.appendChild(tb_line);return tb_line;};HTMLArea.addTbElement=function(element,tb_line,first_cell_on_line){var tb_cell=document.createElement("li");if(first_cell_on_line)tb_cell.className="tb-first-cell";else tb_cell.className="tb-cell";HTMLArea._addClass(tb_cell,element.className);tb_line.appendChild(tb_cell);tb_cell.appendChild(element);if(element.style.display=="none"){tb_cell.style.display="none";if(HTMLArea._hasClass(tb_line,"tb-group"))tb_line.style.display="none";if(HTMLArea._hasClass(tb_cell.previousSibling,"separator"))tb_cell.previousSibling.style.display="none";}return false;};HTMLArea.addTbGroup=function(tb_line,first_cell_on_line){var tb_group=document.createElement("ul");tb_group.className="tb-group";HTMLArea.addTbElement(tb_group,tb_line,first_cell_on_line);return tb_group;};HTMLArea.prototype.createSelect=function(txt,tb_line,first_cell_on_line,labelObj){var options=null,cmd=null,context=null,tooltip="",newObj={created:false,el:null,first:first_cell_on_line,labelUsed:false};switch(txt){case "FontSize":case "FontName":case "FormatBlock":options=this.config[txt];tooltip=HTMLArea.I18N.tooltips[txt.toLowerCase()];cmd=txt;break;default:cmd=txt;var dropdown=this.config.customSelects[cmd];if(typeof(dropdown)!="undefined"){options=dropdown.options;context=dropdown.context;if(typeof(dropdown.tooltip)!="undefined")tooltip=dropdown.tooltip;}break;}if(options){newObj["el"]=document.createElement("select");newObj["el"].className="select";newObj["el"].title=tooltip;newObj["el"].id=this._editorNumber+"-"+txt;newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);var obj={name:txt,elementId:newObj["el"].id,enabled:true,text:false,cmd:cmd,state:HTMLArea.setButtonStatus,context:context,editorNumber:this._editorNumber};this._toolbarObjects[txt]=obj;newObj["el"]._obj=obj;if(labelObj["labelRef"]){labelObj["el"].htmlFor=newObj["el"].id;newObj["labelUsed"]=true;}HTMLArea._addEvent(newObj["el"],"change",HTMLArea.toolBarButtonHandler);for(var i in options){var op=document.createElement("option");op.innerHTML=i;op.value=options[i];if(txt=="FontName"&&!this.config.disablePCexamples){if(HTMLArea.is_gecko)op.setAttribute("style","font-family:"+op.value+";");else op.style.cssText="font-family:"+op.value+";";}newObj["el"].appendChild(op);}newObj["created"]=true;}return newObj;};HTMLArea.prototype.createButton=function(txt,tb_line,first_cell_on_line,labelObj){var btn=null,btnImg=null,newObj={created:false,el:null,first:first_cell_on_line,labelUsed:false};switch(txt){case "separator":newObj["el"]=document.createElement("div");newObj["el"].className="separator";newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);newObj["created"]=true;break;case "space":newObj["el"]=document.createElement("div");newObj["el"].className="space";newObj["el"].innerHTML="&nbsp;";newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);newObj["created"]=true;break;case "TextIndicator":newObj["el"]=document.createElement("div");newObj["el"].appendChild(document.createTextNode("A"));newObj["el"].className="indicator";newObj["el"].title=HTMLArea.I18N.tooltips.textindicator;newObj["el"].id=this._editorNumber+"-"+txt;newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);var obj={name:txt,elementId:newObj["el"].id,enabled:true,active:false,text:false,cmd:"TextIndicator",state:HTMLArea.setButtonStatus};this._toolbarObjects[txt]=obj;newObj["created"]=true;break;default:btn=this.config.btnList[txt];}if(!newObj["created"]&&btn){newObj["el"]=document.createElement("button");newObj["el"].title=btn[0];newObj["el"].className="button";newObj["el"].id=this._editorNumber+"-"+txt;if(btn[5])newObj["el"].style.display="none";newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);var obj={name:txt,elementId:newObj["el"].id,enabled:true,active:false,text:btn[2],cmd:btn[3],state:HTMLArea.setButtonStatus,context:btn[4]||null,selection:btn[6],editorNumber:this._editorNumber};this._toolbarObjects[txt]=obj;newObj["el"]._obj=obj;if(labelObj["labelRef"]){labelObj["el"].htmlFor=newObj["el"].id;newObj["labelUsed"]=true;}HTMLArea._addEvents(newObj["el"],["mouseover","mouseout","mousedown","click"],HTMLArea.toolBarButtonHandler);if(typeof(btn[1])!="string"&&HTMLArea.is_ie){var btnImgContainer=document.createElement("div");btnImgContainer.className="buttonImgContainer";btnImgContainer.innerHTML='<img src="'+btn[1][0]+'" style="position: relative; top: -'+(18*(btn[1][1]+1))+'px; left: -'+(18*(btn[1][2]+1))+'px;" alt="'+btn[0]+'" />';newObj["el"].appendChild(btnImgContainer);}else{newObj["el"].className+=" "+txt;if(this.plugins["TYPO3Browsers"]&&(txt=="CreateLink"||txt=="InsertImage"))newObj["el"].className+="-TYPO3Browsers";}newObj["created"]=true;}return newObj;};HTMLArea.createLabel=function(txt,tb_line,first_cell_on_line){var newObj={created:false,el:null,labelRef:false,first:first_cell_on_line};if(/^([IT])\[(.*?)\]/.test(txt)){var l7ed=RegExp.$1=="I";var label=RegExp.$2;if(l7ed)label=HTMLArea.I18N.dialogs[label];newObj["el"]=document.createElement("label");newObj["el"].className="label";newObj["el"].innerHTML=label;newObj["labelRef"]=true;newObj["created"]=true;newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);}return newObj;};HTMLArea.prototype._createToolbar=function(){var j,k,code,n=this.config.toolbar.length,m,tb_line=null,tb_group=null,first_cell_on_line=true,labelObj=new Object(),tbObj=new Object();var toolbar=document.createElement("div");this._toolbar=toolbar;toolbar.className="toolbar";toolbar.unselectable="1";this._toolbarObjects=new Object();for(j=0;j<n;++j){tb_line=HTMLArea.newLine(toolbar);if(!this.config.keepButtonGroupTogether)HTMLArea._addClass(tb_line,"free-float");first_cell_on_line=true;tb_group=null;var group=this.config.toolbar[j];m=group.length;for(k=0;k<m;++k){code=group[k];if(code=="linebreak"){tb_line=HTMLArea.newLine(toolbar);if(!this.config.keepButtonGroupTogether)HTMLArea._addClass(tb_line,"free-float");first_cell_on_line=true;tb_group=null;}else{if((code=="separator"||first_cell_on_line)&&this.config.keepButtonGroupTogether){tb_group=HTMLArea.addTbGroup(tb_line,first_cell_on_line);first_cell_on_line=false;}created=false;if(/^([IT])\[(.*?)\]/.test(code)){labelObj=HTMLArea.createLabel(code,(tb_group?tb_group:tb_line),first_cell_on_line);created=labelObj["created"];first_cell_on_line=labelObj["first"];}if(!created){tbObj=this.createButton(code,(tb_group?tb_group:tb_line),first_cell_on_line,labelObj);created=tbObj["created"];first_cell_on_line=tbObj["first"];if(tbObj["labelUsed"])labelObj["labelRef"]=false;}if(!created){tbObj=this.createSelect(code,(tb_group?tb_group:tb_line),first_cell_on_line,labelObj);created=tbObj["created"];first_cell_on_line=tbObj["first"];if(tbObj["labelUsed"])labelObj["labelRef"]=false;}if(!created)HTMLArea._appendToLog("ERROR [HTMLArea::createToolbar]: Unknown toolbar item: "+code);}}}tb_line=HTMLArea.newLine(toolbar);this._htmlArea.appendChild(toolbar);};HTMLArea.toolBarButtonHandler=function(ev){if(!ev)var ev=window.event;var target=(ev.target)?ev.target:ev.srcElement;while(target.tagName.toLowerCase()=="img"||target.tagName.toLowerCase()=="div")target=target.parentNode;var obj=target._obj;var editorNumber=obj["editorNumber"];var editor=RTEarea[editorNumber]["editor"];if(obj.enabled){switch(ev.type){case "mouseover":HTMLArea._addClass(target,"buttonHover");HTMLArea._addClass(target.parentNode,"buttonHover");break;case "mouseout":HTMLArea._removeClass(target,"buttonHover");HTMLArea._removeClass(target.parentNode,"buttonHover");HTMLArea._removeClass(target,"buttonActive");HTMLArea._removeClass(target.parentNode,"buttonActive");if(obj.active){HTMLArea._addClass(target,"buttonPressed");HTMLArea._addClass(target.parentNode,"buttonPressed");}break;case "mousedown":HTMLArea._addClass(target,"buttonActive");HTMLArea._addClass(target.parentNode,"buttonActive");HTMLArea._removeClass(target,"buttonPressed");HTMLArea._removeClass(target.parentNode,"buttonPressed");HTMLArea._stopEvent(ev);break;case "click":HTMLArea._removeClass(target,"buttonActive");HTMLArea._removeClass(target.parentNode,"buttonActive");HTMLArea._removeClass(target,"buttonHover");HTMLArea._removeClass(target.parentNode,"buttonHover");obj.cmd(editor,obj.name,obj);HTMLArea._stopEvent(ev);break;case "change":editor.focusEditor();var value=target.options[target.selectedIndex].value;switch(obj.name){case "FontName":case "FontSize":editor.execCommand(obj.name,false,value);break;case "FormatBlock":(HTMLArea.is_ie||HTMLArea.is_safari)&&(value="<"+value+">");editor.execCommand(obj.name,false,value);break;default:var dropdown=editor.config.customSelects[obj.name];if(typeof(dropdown)!="undefined")dropdown.action(editor);else HTMLArea._appendToLog("ERROR [HTMLArea::toolBarButtonHandler]: Combo box "+obj.name+" not registered.");}}}};HTMLArea.prototype._createStatusBar=function(){var statusBar=document.createElement("div");this._statusBar=statusBar;statusBar.className="statusBar";if(!this.config.statusBar)statusBar.style.display="none";var statusBarTree=document.createElement("span");this._statusBarTree=statusBarTree;statusBarTree.className="statusBarTree";statusBar.appendChild(statusBarTree);statusBarTree.appendChild(document.createTextNode(HTMLArea.I18N.msg["Path"]+": "));this._htmlArea.appendChild(statusBar);};HTMLArea.prototype.generate=function(){var textarea=this._textArea;if(typeof(textarea)=="string"){textarea=HTMLArea.getElementById("textarea",textarea);this._textArea=textarea;}textarea.style.display="none";var htmlarea=document.createElement("div");htmlarea.className="htmlarea";htmlarea.style.width=textarea.style.width;this._htmlArea=htmlarea;textarea.parentNode.insertBefore(htmlarea,textarea);if(textarea.form){var f=textarea.form;if(typeof(f.onreset)=="function"){var funcref=f.onreset;if(typeof(f.__msh_prevOnReset)=="undefined")f.__msh_prevOnReset=[];f.__msh_prevOnReset.push(funcref);}f._editorNumber=this._editorNumber;HTMLArea._addEvent(f,"reset",HTMLArea.resetHandler);}this._createToolbar();HTMLArea._appendToLog("[HTMLArea::generate]: Toolbar successfully created.");var iframe=document.createElement("iframe");if(HTMLArea.is_ie||HTMLArea.is_safari||HTMLArea.is_wamcom){iframe.setAttribute("src",_editor_url+"popups/blank.html");}else if(HTMLArea.is_opera){iframe.setAttribute("src",_typo3_host_url+_editor_url+"popups/blank.html");}else{iframe.setAttribute("src","javascript:void(0);");}iframe.className="editorIframe";if(!this.config.statusBar)iframe.className+=" noStatusBar";htmlarea.appendChild(iframe);this._iframe=iframe;this._createStatusBar();this.sizeIframe(2);HTMLArea._appendToLog("[HTMLArea::generate]: Editor iframe successfully created.");this.initIframe();return this;};HTMLArea.prototype.sizeIframe=function(diff){var height=(this.config.height=="auto"?(this._textArea.style.height):this.config.height);var textareaHeight=height;if(height.indexOf("%")==-1){height=parseInt(height)-diff;if(this.config.sizeIncludesToolbar){this._initialToolbarOffsetHeight=this._toolbar.offsetHeight;height-=this._toolbar.offsetHeight;height-=this._statusBar.offsetHeight;}if(height<0)height=0;textareaHeight=(height-4);if(textareaHeight<0)textareaHeight=0;height+="px";textareaHeight+="px";}this._iframe.style.height=height;this._textArea.style.height=textareaHeight;var textareaWidth=(this.config.width=="auto"?this._textArea.style.width:this.config.width);var iframeWidth=textareaWidth;if(textareaWidth.indexOf("%")==-1){iframeWidth=parseInt(textareaWidth)+"px";textareaWidth=parseInt(textareaWidth)-diff;if(textareaWidth<0)textareaWidth=0;textareaWidth+="px";}this._iframe.style.width="100%";if(HTMLArea.is_opera)this._iframe.style.width=iframeWidth;this._textArea.style.width=textareaWidth;};HTMLArea.initIframe=function(editorNumber){var editor=RTEarea[editorNumber]["editor"];editor.initIframe();};HTMLArea.prototype.initIframe=function(){if(this._initIframeTimer)window.clearTimeout(this._initIframeTimer);if(!this._iframe||(!this._iframe.contentWindow&&!this._iframe.contentDocument)){this._initIframeTimer=window.setTimeout("HTMLArea.initIframe("+this._editorNumber+");",50);return false;}else if(this._iframe.contentWindow){if(!this._iframe.contentWindow.document||!this._iframe.contentWindow.document.documentElement){this._initIframeTimer=window.setTimeout("HTMLArea.initIframe("+this._editorNumber+");",50);return false;}}else if(!this._iframe.contentDocument.documentElement){this._initIframeTimer=window.setTimeout("HTMLArea.initIframe("+this._editorNumber+");",50);return false;}var doc=this._iframe.contentWindow?this._iframe.contentWindow.document:this._iframe.contentDocument;this._doc=doc;if(!this.config.fullPage){var head=doc.getElementsByTagName("head")[0];if(!head){head=doc.createElement("head");doc.documentElement.appendChild(head);}if(this.config.baseURL&&!HTMLArea.is_opera){var base=doc.getElementsByTagName("base")[0];if(!base){base=doc.createElement("base");base.href=this.config.baseURL;head.appendChild(base);}HTMLArea._appendToLog("[HTMLArea::initIframe]: Iframe baseURL set to: "+this.config.baseURL);}var link0=doc.getElementsByTagName("link")[0];if(!link0){link0=doc.createElement("link");link0.rel="stylesheet";link0.href=this.config.editedContentStyle;head.appendChild(link0);HTMLArea._appendToLog("[HTMLArea::initIframe]: Skin CSS set to: "+this.config.editedContentStyle);}if(this.config.defaultPageStyle){var link=doc.getElementsByTagName("link")[1];if(!link){link=doc.createElement("link");link.rel="stylesheet";link.href=this.config.defaultPageStyle;head.appendChild(link);}HTMLArea._appendToLog("[HTMLArea::initIframe]: Override CSS set to: "+this.config.defaultPageStyle);}if(this.config.pageStyle){var link=doc.getElementsByTagName("link")[2];if(!link){link=doc.createElement("link");link.rel="stylesheet";link.href=this.config.pageStyle;head.appendChild(link);}HTMLArea._appendToLog("[HTMLArea::initIframe]: Content CSS set to: "+this.config.pageStyle);}}else{var html=this._textArea.value;this.setFullHTML(html);}HTMLArea._appendToLog("[HTMLArea::initIframe]: Editor iframe head successfully initialized.");this.stylesLoaded();};HTMLArea.stylesLoaded=function(editorNumber){var editor=RTEarea[editorNumber]["editor"];editor.stylesLoaded();};HTMLArea.prototype.stylesLoaded=function(){var doc=this._doc;var docWellFormed=true;if(this._stylesLoadedTimer)window.clearTimeout(this._stylesLoadedTimer);var stylesAreLoaded=true;var errorText='';var rules;for(var rule=0;rule<doc.styleSheets.length;rule++){if(HTMLArea.is_gecko)try{rules=doc.styleSheets[rule].cssRules;}catch(e){stylesAreLoaded=false;errorText=e;}if(HTMLArea.is_ie)try{rules=doc.styleSheets[rule].rules;}catch(e){stylesAreLoaded=false;errorText=e;}if(HTMLArea.is_ie)try{rules=doc.styleSheets[rule].imports;}catch(e){stylesAreLoaded=false;errorText=e;}}if(!stylesAreLoaded&&!HTMLArea.is_wamcom){HTMLArea._appendToLog("[HTMLArea::initIframe]: Failed attempt at loading stylesheets: "+errorText+" Retrying...");this._stylesLoadedTimer=window.setTimeout("HTMLArea.stylesLoaded("+this._editorNumber+");",100);return false;}HTMLArea._appendToLog("[HTMLArea::initIframe]: Stylesheets successfully loaded.");if(!this.config.fullPage){doc.body.style.borderWidth="0px";doc.body.className="htmlarea-content-body";try{doc.body.innerHTML=this._textArea.value;}catch(e){HTMLArea._appendToLog("[HTMLArea::initIframe]: The HTML document is not well-formed.");alert(HTMLArea.I18N.msg["HTML-document-not-well-formed"]);docWellFormed=false;}}if(this._customUndo)this._timerUndo=window.setInterval("HTMLArea.undoTakeSnapshot("+this._editorNumber+");",this.config.undoTimeout);if(docWellFormed){if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera&&!this._initEditMode())return false;if(HTMLArea.is_opera)doc.designMode="on";if(HTMLArea.is_ie||HTMLArea.is_safari)doc.body.contentEditable=true;if(HTMLArea.is_ie)doc.selection.empty();this._editMode="wysiwyg";if(doc.body.contentEditable||doc.designMode=="on")HTMLArea._appendToLog("[HTMLArea::initIframe]: Design mode successfully set.");}else{this._editMode="textmode";this.setMode("docnotwellformedmode");HTMLArea._appendToLog("[HTMLArea::initIframe]: Design mode could not be set.");}doc._editorNo=this._editorNumber;if(HTMLArea.is_ie)doc.documentElement._editorNo=this._editorNumber;HTMLArea._addEvents((HTMLArea.is_ie?doc.body:doc),["keydown","keypress","mousedown","mouseup","drag"],HTMLArea._editorEvent,true);HTMLArea._addEvent((this._iframe.contentWindow?this._iframe.contentWindow:this._iframe.contentDocument),"unload",HTMLArea.removeEditorEvents);if(this.config.cleanWordOnPaste)HTMLArea._addEvents((HTMLArea.is_ie?doc.body:doc),["paste","dragdrop","drop"],HTMLArea.cleanWordOnPaste,true);window.setTimeout("HTMLArea.generatePlugins("+this._editorNumber+");",100);};HTMLArea.generatePlugins=function(editorNumber){var editor=RTEarea[editorNumber]["editor"];editor._hasPluginWithOnKeyPressHandler=false;for(var i in editor.plugins){var plugin=editor.plugins[i].instance;if(typeof(plugin.onGenerate)=="function")plugin.onGenerate();if(typeof(plugin.onGenerateOnce)=="function"){plugin.onGenerateOnce();plugin.onGenerateOnce=null;}if(typeof(plugin.onKeyPress)=="function"){editor._hasPluginWithOnKeyPressHandler=true;}}if(typeof(editor.onGenerate)=="function"){editor.onGenerate();editor.onGenerate=null;}HTMLArea._appendToLog("[HTMLArea::initIframe]: All plugins successfully generated.");editor.updateToolbar();};HTMLArea.resetHandler=function(ev){if(!ev)var ev=window.event;var form=(ev.target)?ev.target:ev.srcElement;var editor=RTEarea[form._editorNumber]["editor"];editor.setHTML(editor._textArea.value);editor.updateToolbar();var a=form.__msh_prevOnReset;if(typeof(a)!="undefined"){for(var i=a.length;--i>=0;){a[i]();}}};HTMLArea.removeEditorEvents=function(ev){if(!ev)var ev=window.event;HTMLArea._stopEvent(ev);if(Dialog._modal){Dialog._modal.close();Dialog._modal=null;}for(var ed=RTEarea.length;--ed>0;){var editor=RTEarea[ed]["editor"];if(editor){RTEarea[ed]["editor"]=null;editor._textArea.value=editor.getHTML();window.clearInterval(editor._timerUndo);editor._undoQueue=null;if(HTMLArea._eventCache&&!HTMLArea.is_opera)HTMLArea._eventCache.flush();if(HTMLArea.is_ie)HTMLArea._cleanup(editor);}}};HTMLArea.prototype.setMode=function(mode){if(typeof(mode)=="undefined")var mode=(this._editMode=="textmode")?"wysiwyg":"textmode";switch(mode){case "textmode":case "docnotwellformedmode":this._textArea.value=this.getHTML();this._iframe.style.display="none";this._textArea.style.display="block";if(this.config.statusBar){var statusBarTextMode=document.createElement("span");statusBarTextMode.className="statusBarTextMode";statusBarTextMode.appendChild(document.createTextNode(HTMLArea.I18N.msg["TEXT_MODE"]));this._statusBar.innerHTML='';this._statusBar.appendChild(statusBarTextMode);}this._editMode="textmode";break;case "wysiwyg":if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera)this._doc.designMode="off";try{if(!this.config.fullPage)this._doc.body.innerHTML=this.getHTML();else this.setFullHTML(this.getHTML());}catch(e){alert(HTMLArea.I18N.msg["HTML-document-not-well-formed"]);break;}this._textArea.style.display="none";this._iframe.style.display="block";if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera)this._doc.designMode="on";if(this.config.statusBar){this._statusBar.innerHTML="";this._statusBar.appendChild(this._statusBarTree);}this._editMode="wysiwyg";break;default:return false;}if(!(mode=="docnotwellformedmode"))this.focusEditor();for(var i in this.plugins){var plugin=this.plugins[i].instance;if(typeof(plugin.onMode)=="function"){plugin.onMode(mode);}}};HTMLArea.prototype.setFullHTML=function(html){var save_multiline=RegExp.multiline;RegExp.multiline=true;if(html.match(HTMLArea.RE_doctype)){this.setDoctype(RegExp.$1);html=html.replace(HTMLArea.RE_doctype,"");};RegExp.multiline=save_multiline;if(!HTMLArea.is_ie){if(html.match(HTMLArea.RE_head))this._doc.getElementsByTagName("head")[0].innerHTML=RegExp.$1;if(html.match(HTMLArea.RE_body))this._doc.getElementsByTagName("body")[0].innerHTML=RegExp.$1;}else{var html_re=/<html>((.|\n)*?)<\/html>/i;html=html.replace(html_re,"$1");this._doc.open();this._doc.write(html);this._doc.close();this._doc.body.contentEditable=true;return true;};};HTMLArea.prototype.registerPlugin=function(){var plugin=arguments[0];var args=[];for(var i=1;i<arguments.length;++i){args.push(arguments[i]);}this.registerPlugin2(plugin,args);};HTMLArea.prototype.registerPlugin2=function(plugin,args){if(typeof(plugin)=="string"){var plugin=eval(plugin);};if(typeof(plugin)=="undefined"){HTMLArea._appendToLog("ERROR [HTMLArea::registerPlugin]: Can't register undefined plugin.");return false;};var obj=new plugin(this,args);if(obj){var clone={};var info=plugin._pluginInfo;for(var i in info){clone[i]=info[i];}clone.instance=obj;clone.args=args;this.plugins[plugin._pluginInfo.name]=clone;}else{HTMLArea._appendToLog("ERROR [HTMLArea::registerPlugin]: Can't register plugin "+plugin.toString()+".");};};HTMLArea.loadPlugin=function(pluginName,noLangFile,url){if(typeof(url)=="undefined"){var dir=_editor_url+"plugins/"+pluginName;var plugin=pluginName.replace(/([a-z])([A-Z])([a-z])/g,"$1"+"-"+"$2"+"$3").toLowerCase()+".js";var plugin_file=dir+"/"+plugin;HTMLArea.loadScript(plugin_file);if(typeof(noLangFile)=="undefined"||!noLangFile){var plugin_lang=dir+"/lang/"+_editor_lang+".js";HTMLArea._scripts.push(plugin_lang);}}else{HTMLArea.loadScript(url);}};HTMLArea.loadStyle=function(style,plugin,url){if(typeof(url)=="undefined"){var url=_editor_url||'';if(typeof(plugin)!="undefined"){url+="plugins/"+plugin+"/";}url+=style;if(/^\//.test(style)){url=style;}}var head=document.getElementsByTagName("head")[0];var link=document.createElement("link");link.rel="stylesheet";link.href=url;head.appendChild(link);};HTMLArea.loadStyle('','',_editor_CSS);HTMLArea.prototype.imgURL=function(file,plugin){if(typeof(plugin)=="undefined")return _editor_skin+this.config.imgURL+file;else return _editor_skin+this.config.imgURL+plugin+"/"+file;};HTMLArea.prototype.popupURL=function(file){var url="";if(file.match(/^plugin:\/\/(.*?)\/(.*)/)){var plugin=RegExp.$1;var popup=RegExp.$2;if(!/\.html$/.test(popup))popup+=".html";url=_editor_url+"plugins/"+plugin+"/popups/"+popup;}else{url=_typo3_host_url+_editor_url+this.config.popupURL+file;};return url;};HTMLArea.getInnerText=function(el){var txt='',i;for(i=el.firstChild;i;i=i.nextSibling){if(i.nodeType==3)txt+=i.data;else if(i.nodeType==1)txt+=HTMLArea.getInnerText(i);};return txt;};HTMLArea._wordClean=function(editor,html){function clearClass(node){var newc=node.className.replace(/(^|\s)mso.*?(\s|$)/ig,' ');if(newc!=node.className){node.className=newc;if(!/\S/.test(node.className))node.removeAttribute("className");}};function clearStyle(node){if(HTMLArea.is_ie)var style=node.style.cssText;else var style=node.getAttribute("style");if(style){var declarations=style.split(/\s*;\s*/);for(var i=declarations.length;--i>=0;){if(/^mso|^tab-stops/i.test(declarations[i])||/^margin\s*:\s*0..\s+0..\s+0../i.test(declarations[i]))declarations.splice(i,1);};node.setAttribute("style",declarations.join("; "));}};function stripTag(el){if(HTMLArea.is_ie){el.outerHTML=HTMLArea.htmlEncode(el.innerText);}else{var txt=document.createTextNode(HTMLArea.getInnerText(el));el.parentNode.insertBefore(txt,el);el.parentNode.removeChild(el);}};function checkEmpty(el){if(/^(span|b|strong|i|em|font)$/i.test(el.tagName)&&!el.firstChild)el.parentNode.removeChild(el);};function parseTree(root){var tag=root.tagName.toLowerCase(),i,next;if((HTMLArea.is_ie&&root.scopeName!='HTML')||(!HTMLArea.is_ie&&/:/.test(tag))||/o:p/.test(tag)){stripTag(root);return false;}else{clearClass(root);clearStyle(root);for(i=root.firstChild;i;i=next){next=i.nextSibling;if(i.nodeType==1&&parseTree(i)){checkEmpty(i);}}};return true;};parseTree(html);};HTMLArea.wordCleanLater=function(editorNumber,doUpdateToolbar){var editor=RTEarea[editorNumber]["editor"];HTMLArea._wordClean(editor,editor._doc.body);if(doUpdateToolbar)editor.updateToolbar();};HTMLArea.cleanWordOnPaste=function(ev){if(!ev)var ev=window.event;var target=(ev.target)?ev.target:ev.srcElement;var owner=(target.ownerDocument)?target.ownerDocument:target;while(HTMLArea.is_ie&&owner.parentElement){owner=owner.parentElement;};if(typeof(browserWin)!="undefined")browserWin.close();window.setTimeout("HTMLArea.wordCleanLater("+owner._editorNo+", true);",250);};HTMLArea.prototype.forceRedraw=function(){this._doc.body.style.visibility="hidden";this._doc.body.style.visibility="visible";};HTMLArea.prototype.focusEditor=function(){switch(this._editMode){case "wysiwyg":try{if(HTMLArea.is_safari||HTMLArea.is_opera)this._doc.focus();else this._iframe.contentWindow.focus();}catch(e){};break;case "textmode":this._textArea.focus();break;};return this._doc;};HTMLArea.undoTakeSnapshot=function(editorNumber){var editor=RTEarea[editorNumber]["editor"];if(editor._doc)editor._undoTakeSnapshot();};HTMLArea.prototype._undoTakeSnapshot=function(){var curTime=(new Date()).getTime();var newOne=true;if(this._undoPos>=this.config.undoSteps){this._undoQueue.shift();--this._undoPos;};if(this._undoPos<0||this._undoQueue[this._undoPos].time<curTime-this.config.undoTimeout){++this._undoPos;}else{newOne=false;};var txt=this.getInnerHTML();if(newOne){if(this._undoPos==0||this._undoQueue[this._undoPos-1].text!=txt){this._undoQueue[this._undoPos]={text:txt,time:curTime};this._undoQueue.length=this._undoPos+1;}else{this._undoPos--;}}else{if(this._undoQueue[this._undoPos].text!=txt){this._undoQueue[this._undoPos].text=txt;this._undoQueue.length=this._undoPos+1;}}};HTMLArea.setUndoQueueLater=function(editorNumber,op){var editor=RTEarea[editorNumber]["editor"];if(op=="undo"){editor.setHTML(editor._undoQueue[--editor._undoPos].text);}else if(op=="redo"){if(editor._undoPos<editor._undoQueue.length-1)editor.setHTML(editor._undoQueue[++editor._undoPos].text);}};HTMLArea.prototype.undo=function(){if(this._undoPos>0){this._undoTakeSnapshot();if(!HTMLArea.is_opera)this.setHTML(this._undoQueue[--this._undoPos].text);else window.setTimeout("HTMLArea.setUndoQueueLater("+this._editorNumber+", 'undo');",10);}};HTMLArea.prototype.redo=function(){if(this._undoPos<this._undoQueue.length-1){this._undoTakeSnapshot();if(!HTMLArea.is_opera){if(this._undoPos<this._undoQueue.length-1)this.setHTML(this._undoQueue[++this._undoPos].text);}else{window.setTimeout("HTMLArea.setUndoQueueLater("+this._editorNumber+", 'redo');",10);}}};HTMLArea.updateToolbar=function(editorNumber){var editor=RTEarea[editorNumber]["editor"];editor.updateToolbar();editor._timerToolbar=null;};HTMLArea.prototype.updateToolbar=function(noStatus){var doc=this._doc,text=(this._editMode=="textmode"),selection=this.hasSelectedText(),ancestors=null,cls=new Array(),txt,txtClass,i,cmd,inContext,match,matchAny,k,j,n,commandState;if(!text){ancestors=this.getAllAncestors();if(this.config.statusBar&&!noStatus){if(this._statusBarTree.hasChildNodes()){for(i=this._statusBarTree.firstChild;i;i=i.nextSibling){if(i.nodeName.toLowerCase()=="a"){HTMLArea._removeEvents(i,["click","contextmenu, mousedown"],HTMLArea.statusBarHandler);i.el=null;i.editor=null;}}};this._statusBarTree.innerHTML='';this._statusBarTree.appendChild(document.createTextNode(HTMLArea.I18N.msg["Path"]+": "));for(i=ancestors.length;--i>=0;){var el=ancestors[i];if(!el)continue;var a=document.createElement("a");a.href="#";a.el=el;a.editor=this;if(!HTMLArea.is_opera){HTMLArea._addEvents(a,["click","contextmenu"],HTMLArea.statusBarHandler);}else{HTMLArea._addEvents(a,["mousedown","click"],HTMLArea.statusBarHandler);};txt=el.tagName.toLowerCase();a.title=el.style.cssText;if(el.id){txt+="#"+el.id;};if(el.className){txtClass="";cls=el.className.trim().split(" ");for(j=cls.length;j>0;){if(!HTMLArea.reservedClassNames.test(cls[--j])){txtClass="."+cls[j];}};txt+=txtClass;};a.appendChild(document.createTextNode(txt));this._statusBarTree.appendChild(a);if(i!=0)this._statusBarTree.appendChild(document.createTextNode(String.fromCharCode(0xbb)));}}};for(i in this._toolbarObjects){var btn=this._toolbarObjects[i];cmd=i;inContext=true;if(btn.context&&!text){inContext=false;var attrs=[];var contexts=[];if(/(.*)\[(.*?)\]/.test(btn.context)){contexts=RegExp.$1.split(",");attrs=RegExp.$2.split(",");}else{contexts=btn.context.split(",");};for(j=contexts.length;--j>=0;)contexts[j]=contexts[j].toLowerCase();matchAny=(contexts[0]=="*");for(k=0;k<ancestors.length;++k){if(!ancestors[k])continue;match=false;for(j=contexts.length;--j>=0;)match=match||(ancestors[k].tagName.toLowerCase()==contexts[j]);if(matchAny||match){inContext=true;for(j=attrs.length;--j>=0;){if(!eval("ancestors[k]."+attrs[j])){inContext=false;break;}};if(inContext)break;}}};if(cmd=="CreateLink")btn.state("enabled",(!text||btn.text)&&(inContext||selection));else btn.state("enabled",(!text||btn.text)&&inContext&&(selection||!btn.selection));if(typeof(cmd)=="function"){continue;};var dropdown=this.config.customSelects[cmd];if((!text||btn.text)&&(typeof(dropdown)!="undefined")){dropdown.refresh(this);continue;};switch(cmd){case "FontName":case "FontSize":if(!text)try{var value=(""+doc.queryCommandValue(cmd)).toLowerCase();if(!value){document.getElementById(btn.elementId).selectedIndex=0;break;};var options=this.config[cmd];k=0;for(j in options){if((j.toLowerCase()==value)||(options[j].substr(0,value.length).toLowerCase()==value)){document.getElementById(btn.elementId).selectedIndex=k;throw "ok";};++k;};document.getElementById(btn.elementId).selectedIndex=0;}catch(e){};break;case "FormatBlock":var blocks=[];for(var i in this.config['FormatBlock']){blocks[blocks.length]=this.config['FormatBlock'][i];};var deepestAncestor=this._getFirstAncestor(this._getSelection(),blocks);if(deepestAncestor){for(var x=0;x<blocks.length;x++){if(blocks[x].toLowerCase()==deepestAncestor.tagName.toLowerCase())document.getElementById(btn.elementId).selectedIndex=x;}}else{document.getElementById(btn.elementId).selectedIndex=0;};break;case "TextIndicator":if(!text){try{with(document.getElementById(btn.elementId).style){backgroundColor=HTMLArea._makeColor(doc.queryCommandValue((HTMLArea.is_ie||HTMLArea.is_safari)?"BackColor":"HiliteColor"));if(/transparent/i.test(backgroundColor)){backgroundColor=HTMLArea._makeColor(doc.queryCommandValue("BackColor"));}color=HTMLArea._makeColor(doc.queryCommandValue("ForeColor"));fontFamily=doc.queryCommandValue("FontName");fontWeight="normal";fontStyle="normal";try{fontWeight=doc.queryCommandState("Bold")?"bold":"normal";}catch(ex){fontWeight="normal";};try{fontStyle=doc.queryCommandState("Italic")?"italic":"normal";}catch(ex){fontStyle="normal";};}}catch(e){}};break;case "HtmlMode":btn.state("active",text);break;case "LeftToRight":case "RightToLeft":var el=this.getParentElement();while(el&&!HTMLArea.isBlockElement(el)){el=el.parentNode;};if(el)btn.state("active",(el.style.direction==((cmd=="RightToLeft")?"rtl":"ltr")));break;case "Bold":case "Italic":case "StrikeThrough":case "Underline":case "Subscript":case "Superscript":case "JustifyLeft":case "JustifyCenter":case "JustifyRight":case "JustifyFull":case "Indent":case "Outdent":case "InsertOrderedList":case "InsertUnorderedList":commandState=false;if(!text)try{commandState=doc.queryCommandState(cmd);}catch(e){commandState=false;};btn.state("active",commandState);break;default:break;}};if(this._customUndo)this._undoTakeSnapshot();for(i in this.plugins){var plugin=this.plugins[i].instance;if(typeof(plugin.onUpdateToolbar)=="function")plugin.onUpdateToolbar();}};HTMLArea.prototype.surroundHTML=function(startTag,endTag){this.insertHTML(startTag+this.getSelectedHTML().replace(HTMLArea.Reg_body,"")+endTag);};HTMLArea.prototype.convertNode=function(el,newTagName){var newel=this._doc.createElement(newTagName),p=el.parentNode;while(el.firstChild)newel.appendChild(el.firstChild);p.insertBefore(newel,el);p.removeChild(el);return newel;};HTMLArea.getElementObject=function(el,tagName){var oEl=el;while(oEl!=null&&oEl.nodeName.toLowerCase()!=tagName)oEl=oEl.parentNode;return oEl;};HTMLArea.prototype.makeNestedList=function(el){var previous,clone;for(var i=el.firstChild;i;i=i.nextSibling){if(/^li$/i.test(i.tagName)){for(var j=i.firstChild;j;j=j.nextSibling){if(/^(ol|ul)$/i.test(j.tagName))this.makeNestedList(j);}}else if(/^(ol|ul)$/i.test(i.tagName)){previous=i.previousSibling;var clone=i.cloneNode(true);if(!previous){previous=el.insertBefore(this._doc.createElement("li"),i);previous.appendChild(clone);}else{previous.appendChild(clone);};HTMLArea.removeFromParent(i);this.makeNestedList(el);break;}}};HTMLArea.prototype.hasSelectedText=function(){return this.getSelectedHTML()!="";};HTMLArea.prototype.getAllAncestors=function(){var p=this.getParentElement();var a=[];while(p&&(p.nodeType==1)&&(p.tagName.toLowerCase()!='body')){a.push(p);p=p.parentNode;};a.push(this._doc.body);return a;};HTMLArea.prototype._getFirstAncestor=function(sel,types){var prnt=this._activeElement(sel);if(prnt==null){try{prnt=(HTMLArea.is_ie?this._createRange(sel).parentElement():this._createRange(sel).commonAncestorContainer);}catch(e){return null;}};if(typeof(types)=='string')types=[types];while(prnt){if(prnt.nodeType==1){if(types==null)return prnt;for(var i=0;i<types.length;i++){if(prnt.tagName.toLowerCase()==types[i])return prnt;};if(prnt.tagName.toLowerCase()=='body')break;if(prnt.tagName.toLowerCase()=='table')break;};prnt=prnt.parentNode;};return null;};HTMLArea.createLinkDialog=function(editor,link){return(function(param){if(!param||typeof(param.f_href)=="undefined")return false;var a=link;if(!a){try{editor._doc.execCommand("CreateLink",false,param.f_href);a=editor.getParentElement();var sel=editor._getSelection();var range=editor._createRange(sel);if(!HTMLArea.is_ie){a=range.startContainer;if(!/^a$/i.test(a.tagName)){a=a.nextSibling;if(a==null)a=range.startContainer.parentNode;}}}catch(e){}}else{var href=param.f_href.trim();editor.selectNodeContents(a);if(href==""){editor._doc.execCommand("Unlink",false,null);editor.updateToolbar();return false;}else{a.href=href;}};if(!(a&&/^a$/i.test(a.tagName)))return false;if(typeof(param.f_target)!="undefined")a.target=param.f_target.trim();if(typeof(param.f_title)!="undefined")a.title=param.f_title.trim();editor.selectNodeContents(a);editor.updateToolbar();editor=null;link=null;});};HTMLArea.prototype._createLink=function(link){var outparam=null;this.focusEditor();if(typeof(link)=="undefined"){link=this.getParentElement();if(link){if(/^img$/i.test(link.tagName))link=link.parentNode;if(!/^a$/i.test(link.tagName))link=null;}};if(!link){var sel=this._getSelection();if(this._selectionEmpty(sel)){alert("You need to select some text before creating a link");return;};outparam={f_href:'',f_title:'',f_target:'',f_usetarget:this.config.makeLinkShowsTarget};}else{outparam={f_href:HTMLArea.is_ie?this.stripBaseURL(link.href):link.getAttribute("href"),f_title:link.title,f_target:link.target,f_usetarget:this.config.makeLinkShowsTarget};};var createLinkDialogFunctRef=HTMLArea.createLinkDialog(this,link);this._popupDialog("link.html",createLinkDialogFunctRef,outparam,450,145);};HTMLArea.insertImageDialog=function(editor,image){return(function(param){if(!param||typeof(param.f_url)=="undefined")return false;var img=image;if(!img){var sel=editor._getSelection();var range=editor._createRange(sel);editor._doc.execCommand("InsertImage",false,param.f_url);if(HTMLArea.is_ie){img=range.parentElement();if(img.tagName.toLowerCase()!="img")img=img.previousSibling;}else{var sel=editor._getSelection();var range=editor._createRange(sel);img=range.startContainer;if(HTMLArea.is_opera)img=img.parentNode;img=img.lastChild;while(img&&img.nodeName.toLowerCase()!="img")img=img.previousSibling;}}else{img.src=param.f_url;};for(var field in param){var value=param[field];switch(field){case "f_alt":img.alt=value;break;case "f_border":if(parseInt(value)){img.style.borderWidth=parseInt(value)+"px";img.style.borderStyle="solid";}else{img.style.borderWidth="";img.style.borderStyle="none";};break;case "f_align":img.style.verticalAlign=value;break;case "f_vert":if(parseInt(value)){img.style.marginTop=parseInt(value)+"px";img.style.marginBottom=parseInt(value)+"px";}else{img.style.marginTop="";img.style.marginBottom="";};break;case "f_horiz":if(parseInt(value)){img.style.marginLeft=parseInt(value)+"px";img.style.marginRight=parseInt(value)+"px";}else{img.style.marginLeft="";img.style.marginRight="";};break;case "f_float":if(HTMLArea.is_ie)img.style.styleFloat=value;else img.style.cssFloat=value;break;}}editor=null;image=null;});};HTMLArea.prototype._insertImage=function(image){var outparam=null;this.focusEditor();if(typeof(image)=="undefined"){var image=this.getParentElement();if(image&&!/^img$/i.test(image.tagName))image=null;};if(image)outparam={f_base:this.config.baseURL,f_url:image.getAttribute("src"),f_alt:image.alt,f_border:isNaN(parseInt(image.style.borderWidth))?"":parseInt(image.style.borderWidth),f_align:image.style.verticalAlign,f_vert:isNaN(parseInt(image.style.marginTop))?"":parseInt(image.style.marginTop),f_horiz:isNaN(parseInt(image.style.marginLeft))?"":parseInt(image.style.marginLeft),f_float:HTMLArea.is_ie?image.style.styleFloat:image.style.cssFloat};var insertImageDialogFunctRef=HTMLArea.insertImageDialog(this,image);this._popupDialog("insert_image.html",insertImageDialogFunctRef,outparam,580,460);};HTMLArea.insertTableDialog=function(editor,sel,range){return(function(param){if(!param)return false;var doc=editor._doc;var table=doc.createElement("table");for(var field in param){var value=param[field];if(!value)continue;switch(field){case "f_width":if(value!="")table.style.width=parseInt(value)+param["f_unit"];break;case "f_align":table.style.textAlign=value;break;case "f_border":if(value!=""){table.style.borderWidth=parseInt(value)+"px";table.style.borderStyle="solid";};break;case "f_spacing":if(value!="")table.cellSpacing=parseInt(value);break;case "f_padding":if(value!="")table.cellPadding=parseInt(value);break;case "f_float":if(HTMLArea.is_ie)table.style.styleFloat=((value!="not set")?value:"");else table.style.cssFloat=((value!="not set")?value:"");break;}};var cellwidth=0;if(param.f_fixed)cellwidth=Math.floor(100/parseInt(param.f_cols));var tbody=doc.createElement("tbody");table.appendChild(tbody);for(var i=param["f_rows"];i>0;i--){var tr=doc.createElement("tr");tbody.appendChild(tr);for(var j=param["f_cols"];j>0;j--){var td=doc.createElement("td");if(cellwidth)td.style.width=cellwidth+"%";if(HTMLArea.is_opera){td.innerHTML='&nbsp;';}tr.appendChild(td);}}editor.focusEditor();if(HTMLArea.is_ie)range.pasteHTML(table.outerHTML);else editor.insertNodeAtSelection(table);if(editor.config.buttons["toggleborders"]&&editor.config.buttons["toggleborders"]["setOnTableCreation"])editor.plugins["TableOperations"].instance.buttonPress(editor,"TO-toggle-borders");if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera)editor.setMode("wysiwyg");editor.updateToolbar();editor=null;sel=null;range=null;return true;});};HTMLArea.prototype._insertTable=function(){var sel=this._getSelection();var range=this._createRange(sel);this.focusEditor();var insertTableDialogFunctRef=HTMLArea.insertTableDialog(this,sel,range);this._popupDialog("insert_table.html",insertTableDialogFunctRef,this,520,230);};HTMLArea.selectColorDialog=function(editor,cmdID){return(function(color){if(color)editor._doc.execCommand(cmdID,false,"#"+color);});};HTMLArea.prototype.execCommand=function(cmdID,UI,param){this.focusEditor();if(HTMLArea.is_gecko){try{this._doc.execCommand("useCSS",false,!this.config.useCSS);}catch(e){};try{this._doc.execCommand("styleWithCSS",false,this.config.useCSS);}catch(e){};}switch(cmdID){case "HtmlMode":this.setMode();break;case "SplitBlock":this._doc.execCommand('FormatBlock',false,((HTMLArea.is_ie||HTMLArea.is_safari)?"<div>":"div"));break;case "HiliteColor":(HTMLArea.is_ie||HTMLArea.is_safari)&&(cmdID="BackColor");case "ForeColor":var colorDialogFunctRef=HTMLArea.selectColorDialog(this,cmdID);this._popupDialog("select_color.html",colorDialogFunctRef,HTMLArea._colorToRgb(this._doc.queryCommandValue(cmdID)),200,182);break;case "CreateLink":this._createLink();break;case "Undo":case "Redo":if(this._customUndo)this[cmdID.toLowerCase()]();else this._doc.execCommand(cmdID,UI,param);break;case "InsertTable":this._insertTable();break;case "InsertImage":this._insertImage();break;case "About":this._popupDialog("about.html",null,this,475,350);break;case "CleanWord":HTMLArea._wordClean(this,this._doc.body);break;case "Cut":case "Copy":case "Paste":try{this._doc.execCommand(cmdID,false,null);if(cmdID=="Paste"&&this.config.cleanWordOnPaste)HTMLArea._wordClean(this,this._doc.body);}catch(e){if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera)this._mozillaPasteException(cmdID,UI,param);}break;case "LeftToRight":case "RightToLeft":var dir=(cmdID=="RightToLeft")?"rtl":"ltr";var el=this.getParentElement();while(el&&!HTMLArea.isBlockElement(el))el=el.parentNode;if(el){if(el.style.direction==dir)el.style.direction="";else el.style.direction=dir;}break;case "Indent":var el=this.getParentElement();while(el&&(!HTMLArea.isBlockElement(el)||/^li$/i.test(el.nodeName)))el=el.parentNode;try{this._doc.execCommand(cmdID,UI,param);}catch(e){if(this.config.debug)alert(e+"\n\nby execCommand("+cmdID+");");}if(/^(ol|ul)$/i.test(el.nodeName)){this.makeNestedList(el);this.selectNodeContents(el);}break;case "FontSize":case "FontName":if(param){this._doc.execCommand(cmdID,UI,param);break;}else{var sel=this._getSelection();if(HTMLArea.is_gecko&&sel.isCollapsed){var fontNode=this._getFirstAncestor(sel,"font");if(fontNode!=null)this.selectNode(fontNode);}this._doc.execCommand("RemoveFormat",UI,null);if(HTMLArea.is_gecko&&fontNode!=null){sel=this._getSelection();var r=this._createRange(sel).cloneRange();r.collapse(false);if(HTMLArea.is_safari){sel.empty();sel.setBaseAndExtent(r.startContainer,r.startOffset,r.endContainer,r.endOffset);}else{sel.removeAllRanges();sel.addRange(r);}}}break;default:try{this._doc.execCommand(cmdID,UI,param);}catch(e){if(this.config.debug)alert(e+"\n\nby execCommand("+cmdID+");");}}this.updateToolbar();return false;};HTMLArea._editorEvent=function(ev){if(!ev)var ev=window.event;var target=(ev.target)?ev.target:ev.srcElement;var owner=(target.ownerDocument)?target.ownerDocument:target;if(HTMLArea.is_ie){while(owner.parentElement){owner=owner.parentElement;}}var editor=RTEarea[owner._editorNo]["editor"];var keyEvent=((HTMLArea.is_ie||HTMLArea.is_safari)&&ev.type=="keydown")||(!HTMLArea.is_ie&&ev.type=="keypress");editor.focusEditor();if(keyEvent){if(editor._hasPluginWithOnKeyPressHandler){for(var i in editor.plugins){var plugin=editor.plugins[i].instance;if(typeof(plugin.onKeyPress)=="function"){if(plugin.onKeyPress(ev))return false;}}}if(ev.ctrlKey){if(!ev.altKey){var key=String.fromCharCode((HTMLArea.is_ie||HTMLArea.is_safari||HTMLArea.is_opera)?ev.keyCode:ev.charCode).toLowerCase();if(HTMLArea.is_gecko&&ev.keyCode==32)key=String.fromCharCode(ev.keyCode).toLowerCase();var cmd=null;var value=null;switch(key){case '1':case '2':case '3':case '4':case '5':case '6':if(editor._toolbarObjects["FormatBlock"]){cmd="FormatBlock";value="h"+key;if(HTMLArea.is_ie||HTMLArea.is_safari)value="<"+value+">";}break;case ' ':editor.insertHTML("&nbsp;");editor.updateToolbar();HTMLArea._stopEvent(ev);return false;default:if(editor.config.hotKeyList[key]){switch(editor.config.hotKeyList[key]){case "SelectAll":case "CleanWord":cmd=editor.config.hotKeyList[key];break;case "Paste":if(HTMLArea.is_ie||HTMLArea.is_safari){cmd=editor.config.hotKeyList[key];}else if(editor.config.cleanWordOnPaste){window.setTimeout("HTMLArea.wordCleanLater("+owner._editorNo+", false);",50);}break;default:if(editor._toolbarObjects[editor.config.hotKeyList[key]]){cmd=editor.config.hotKeyList[key];if(cmd=="FormatBlock")value=(HTMLArea.is_ie||HTMLArea.is_safari)?"<p>":"p";}}}}if(cmd){editor.execCommand(cmd,false,value);HTMLArea._stopEvent(ev);return false;}else{editor.updateToolbar();}}}else if(ev.altKey){if(editor.plugins['ContextMenu']&&editor.plugins['ContextMenu'].instance){var keys=editor.plugins['ContextMenu'].instance.keys;if(keys.length>0){var k;for(var i=keys.length;--i>=0;){k=keys[i];if(k[0].toLowerCase()==key){HTMLArea._stopEvent(ev);return false;}}}}}else if(keyEvent){if(HTMLArea.is_gecko)editor._detectURL(ev);switch(ev.keyCode){case 13:if(HTMLArea.is_gecko&&!ev.shiftKey&&!editor.config.disableEnterParagraphs){editor._checkInsertP();HTMLArea._stopEvent(ev);editor.updateToolbar();}break;case 8:case 46:if((HTMLArea.is_gecko&&!ev.shiftKey)||HTMLArea.is_ie){if(editor._checkBackspace())HTMLArea._stopEvent(ev);}if(editor._timerToolbar)window.clearTimeout(editor._timerToolbar);editor._timerToolbar=window.setTimeout("HTMLArea.updateToolbar("+editor._editorNumber+");",50);break;case 9:if(HTMLArea.is_gecko){editor.execCommand((ev.shiftKey?"Outdent":"Indent"),false,null);HTMLArea._stopEvent(ev);return false;}break;case 37:case 39:if(HTMLArea.is_ie){editor._timerToolbar=window.setTimeout("HTMLArea.updateToolbar("+editor._editorNumber+");",10);break;}}}}else{if(editor._timerToolbar)window.clearTimeout(editor._timerToolbar);if(ev.type=="mouseup")editor.updateToolbar();else editor._timerToolbar=window.setTimeout("HTMLArea.updateToolbar("+editor._editorNumber+");",50);}};HTMLArea.prototype.scrollToCaret=function(){var e=this.getParentElement(),w=this._iframe.contentWindow?this._iframe.contentWindow:window,h=w.innerHeight||w.height,d=this._doc,t=d.documentElement.scrollTop||d.body.scrollTop;if(typeof(h)=="undefined")return false;if(e.offsetTop>h+t)w.scrollTo(e.offsetLeft,e.offsetTop-h+e.offsetHeight);};HTMLArea.prototype.getHTML=function(){switch(this._editMode){case "wysiwyg":if(!this.config.fullPage){return HTMLArea.getHTML(this._doc.body,false,this);}else{return this.doctype+"\n"+HTMLArea.getHTML(this._doc.documentElement,true,this);}case "textmode":return this._textArea.value;}return false;};HTMLArea.prototype.getInnerHTML=function(){switch(this._editMode){case "wysiwyg":if(!this.config.fullPage)return this._doc.body.innerHTML;else return this.doctype+"\n"+this._doc.documentElement.innerHTML;case "textmode":return this._textArea.value;}return false;};HTMLArea.prototype.setHTML=function(html){switch(this._editMode){case "wysiwyg":if(!this.config.fullPage)this._doc.body.innerHTML=html;else this._doc.body.innerHTML=html;break;case "textmode":this._textArea.value=html;break;}return false;};HTMLArea.prototype.setDoctype=function(doctype){this.doctype=doctype;};HTMLArea._object=null;HTMLArea.checkSupportedBrowser=function(){if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera){if(navigator.productSub<20030210)return false;}return HTMLArea.is_gecko||HTMLArea.is_ie;};HTMLArea._eventCacheConstructor=function(){var listEvents=[];return({listEvents:listEvents,add:function(node,sEventName,fHandler){listEvents.push(arguments);},flush:function(){var item;for(var i=listEvents.length;--i>=0;){item=listEvents[i];try{HTMLArea._removeEvent(item[0],item[1],item[2]);item[0][item[1]]=null;item[0]=null;item[2]=null;}catch(e){}}}});};HTMLArea._addEvent=function(el,evname,func,useCapture){if(typeof(useCapture)=="undefined")var useCapture=false;if(HTMLArea.is_gecko){el.addEventListener(evname,func,!HTMLArea.is_opera||useCapture);}else{el.attachEvent("on"+evname,func);}HTMLArea._eventCache.add(el,evname,func);};HTMLArea._addEvents=function(el,evs,func,useCapture){if(typeof(useCapture)=="undefined")var useCapture=false;for(var i=evs.length;--i>=0;){HTMLArea._addEvent(el,evs[i],func,useCapture);}};HTMLArea._removeEvent=function(el,evname,func){if(HTMLArea.is_gecko){try{el.removeEventListener(evname,func,true);el.removeEventListener(evname,func,false);}catch(e){}}else{try{el.detachEvent("on"+evname,func);}catch(e){}}};HTMLArea._removeEvents=function(el,evs,func){for(var i=evs.length;--i>=0;){HTMLArea._removeEvent(el,evs[i],func);}};HTMLArea._stopEvent=function(ev){if(HTMLArea.is_gecko){ev.stopPropagation();ev.preventDefault();}else{ev.cancelBubble=true;ev.returnValue=false;}};HTMLArea._removeClass=function(el,removeClassName){if(!(el&&el.className))return;var cls=el.className.trim().split(" ");var ar=new Array();for(var i=cls.length;i>0;){if(cls[--i]!=removeClassName)ar[ar.length]=cls[i];}if(ar.length==0){if(!HTMLArea.is_opera)el.removeAttribute(HTMLArea.is_gecko?"class":"className");else el.className='';}else el.className=ar.join(" ");};HTMLArea._addClass=function(el,addClassName){HTMLArea._removeClass(el,addClassName);if(el.className)el.className+=" "+addClassName;else el.className=addClassName;};HTMLArea._hasClass=function(el,className){if(!el||!el.className)return false;var cls=el.className.split(" ");for(var i=cls.length;i>0;){if(cls[--i]==className)return true;}return false;};HTMLArea.RE_blockTags=/^(body|p|h1|h2|h3|h4|h5|h6|ul|ol|pre|dl|div|noscript|blockquote|form|hr|table|fieldset|address|td|tr|th|li|tbody|thead|tfoot|iframe|object)$/;HTMLArea.isBlockElement=function(el){return el&&el.nodeType==1&&HTMLArea.RE_blockTags.test(el.nodeName.toLowerCase());};HTMLArea.RE_closingTags=/^(p|span|a|li|ol|ul|dl|dt|td|th|tr|tbody|thead|tfoot|caption|table|div|em|i|strong|b|code|cite|blockquote|q|dfn|abbr|acronym|font|center|object|embed|tt|style|script|title|head|clickenlarge)$/;HTMLArea.RE_noClosingTag=/^(img|br|hr|input|area|base|link|meta|param)$/;HTMLArea.needsClosingTag=function(el){return el&&el.nodeType==1&&!HTMLArea.RE_noClosingTag.test(el.tagName.toLowerCase());};HTMLArea.htmlDecode=function(str){str=str.replace(/&lt;/g,"<").replace(/&gt;/g,">");str=str.replace(/&nbsp;/g,"\xA0");str=str.replace(/&quot;/g,"\x22");str=str.replace(/&#39;/g,"'");str=str.replace(/&amp;/g,"&");return str;};HTMLArea.htmlEncode=function(str){if(typeof(str)!='string')str=str.toString();str=HTMLArea.htmlDecode(str);str=str.replace(/&/g,"&amp;");str=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");str=str.replace(/\xA0/g,"&nbsp;");str=str.replace(/\x22/g,"&quot;");str=str.replace(HTMLArea.Reg_entities,"&$1;");return str;};HTMLArea.getHTML=function(root,outputRoot,editor){try{return HTMLArea.getHTMLWrapper(root,outputRoot,editor);}catch(e){HTMLArea._appendToLog("The HTML document is not well-formed.");if(!HTMLArea._debugMode)alert(HTMLArea.I18N.msg["HTML-document-not-well-formed"]);else return HTMLArea.getHTMLWrapper(root,outputRoot,editor);return editor._doc.body.innerHTML;}};HTMLArea.getHTMLWrapper=function(root,outputRoot,editor){var html="";if(!root)return html;switch(root.nodeType){case 1:case 11:case 9:var closed,i,config=editor.config;var root_tag=(root.nodeType==1)?root.tagName.toLowerCase():'';if(root_tag=='br'&&config.removeTrailingBR&&!root.nextSibling&&HTMLArea.isBlockElement(root.parentNode)&&(!root.previousSibling||root.previousSibling.nodeName.toLowerCase()!='br'))break;if(config.htmlRemoveTagsAndContents&&config.htmlRemoveTagsAndContents.test(root_tag))break;var custom_tag=(config.customTags&&config.customTags.test(root_tag));var empty_root=(root_tag=="clickenlarge"&&!(root.firstChild&&root.firstChild.nodeName.toLowerCase()=="img"));if(outputRoot)outputRoot=!(config.htmlRemoveTags&&config.htmlRemoveTags.test(root_tag))&&!empty_root;if((HTMLArea.is_ie||HTMLArea.is_safari)&&root_tag=="head"){if(outputRoot)html+="<head>";var save_multiline=RegExp.multiline;RegExp.multiline=true;var txt=root.innerHTML.replace(HTMLArea.RE_tagName,function(str,p1,p2){return p1+p2.toLowerCase();});RegExp.multiline=save_multiline;html+=txt;if(outputRoot)html+="</head>";break;}else if(outputRoot){if(HTMLArea.is_gecko&&root.hasAttribute('_moz_editor_bogus_node'))break;closed=(!(root.hasChildNodes()||HTMLArea.needsClosingTag(root)||custom_tag));html="<"+root_tag;var a,name,value,attrs=root.attributes;var n=attrs.length;for(i=attrs.length;--i>=0;){a=attrs.item(i);name=a.nodeName.toLowerCase();if((!a.specified&&name!='value')||/_moz|contenteditable|_msh/.test(name))continue;if(!HTMLArea.is_ie||name!="style"){if(typeof(root[a.nodeName])!="undefined"&&name!="href"&&name!="src"&&name!="style"&&!/^on/.test(name)){value=root[a.nodeName];}else{value=a.nodeValue;if(HTMLArea.is_ie&&(name=="href"||name=="src"))value=editor.stripBaseURL(value);}}else{value=root.style.cssText;}if(/(_moz|^$)/.test(value))continue;if(HTMLArea.is_ie&&root_tag=="li"&&name=="value"&&a.nodeValue==0)continue;html+=" "+name+'="'+HTMLArea.htmlEncode(value)+'"';}if(html!="")html+=closed?" />":">";}for(i=root.firstChild;i;i=i.nextSibling){if(/^li$/i.test(i.tagName)&&!/^[ou]l$/i.test(root.tagName))html +="<ul>" +HTMLArea.getHTMLWrapper(i,true,editor)+"</ul>";else html+=HTMLArea.getHTMLWrapper(i,true,editor);}if(outputRoot&&!closed)html+="</"+root_tag+">";break;case 3:html=/^(script|style)$/i.test(root.parentNode.tagName)?root.data:HTMLArea.htmlEncode(root.data);break;case 8:if(!editor.config.htmlRemoveComments)html="<!--"+root.data+"-->";break;case 4:html+='<![CDATA['+root.data+']]>';break;case 5:html+='&'+root.nodeValue+';';break;case 7:html+='<?'+root.target+' '+root.data+' ?>';break;default:break;}return html;};HTMLArea.getPrevNode=function(node){if(!node)return null;if(node.previousSibling)return node.previousSibling;if(node.parentNode)return node.parentNode;return null;};HTMLArea.getNextNode=function(node){if(!node)return null;if(node.nextSibling)return node.nextSibling;if(node.parentNode)return node.parentNode;return null;};HTMLArea.removeFromParent=function(el){if(!el.parentNode)return;var pN=el.parentNode;pN.removeChild(el);return el;};HTMLArea.prototype.stripBaseURL=function(string){var baseurl=this.config.baseURL;baseurl=baseurl.replace(/[^\/]+$/,'');var basere=new RegExp(baseurl);string=string.replace(basere,"");baseurl=baseurl.replace(/^(https?:\/\/[^\/]+)(.*)$/,'$1');basere=new RegExp(baseurl);return string.replace(basere,"");};String.prototype.trim=function(){return this.replace(/^\s+/,'').replace(/\s+$/,'');};HTMLArea._makeColor=function(v){if(typeof(v)!="number"){return v;}var r=v&0xFF;var g=(v>>8)&0xFF;var b=(v>>16)&0xFF;return "rgb("+r+","+g+","+b+")";};HTMLArea._colorToRgb=function(v){if(!v)return '';function hex(d){return(d<16)?("0"+d.toString(16)):d.toString(16);};if(typeof(v)=="number"){var r=v&0xFF;var g=(v>>8)&0xFF;var b=(v>>16)&0xFF;return "#"+hex(r)+hex(g)+hex(b);}if(v.substr(0,3)=="rgb"){var re=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/;if(v.match(re)){var r=parseInt(RegExp.$1);var g=parseInt(RegExp.$2);var b=parseInt(RegExp.$3);return "#"+hex(r)+hex(g)+hex(b);}return null;}if(v.substr(0,1)=="#"){return v;}return null;};HTMLArea._postback=function(url,data,handler,addParams,charset){if(typeof(charset)=="undefined")var charset="utf-8";var req=null;if(window.XMLHttpRequest)req=new XMLHttpRequest();else if(window.ActiveXObject){var success=false;for(var k=0;k<HTMLArea.MSXML_XMLHTTP_PROGIDS.length&&!success;k++){try{req=new ActiveXObject(HTMLArea.MSXML_XMLHTTP_PROGIDS[k]);success=true;}catch(e){}}}if(req){var content='';for(var i in data)content+=(content.length?'&':'')+i+'='+encodeURIComponent(data[i]);content+=(content.length?'&':'')+'charset='+charset;if(typeof(addParams)!="undefined")content+=addParams;if(url.substring(0,1)=='/'){var postUrl=_typo3_host_url+url;}else{var postUrl=_typo3_host_url+_editor_url+url;}function callBack(){if(req.readyState==4){if(req.status==200){if(typeof(handler)=='function')handler(req.responseText,req);HTMLArea._appendToLog("[HTMLArea::_postback]: Server response: "+req.responseText);}else{HTMLArea._appendToLog("ERROR [HTMLArea::_postback]: Unable to post "+postUrl+" . Server reported "+req.statusText);}}}req.onreadystatechange=callBack;function sendRequest(){HTMLArea._appendToLog("[HTMLArea::_postback]: Request: "+content);req.send(content);}req.open('POST',postUrl,true);req.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');window.setTimeout(sendRequest,500);}};Dialog=function(url,action,init,width,height,opener,editor,scrollbars){Dialog._open(url,action,init,(width?width:100),(height?height:100),opener,editor,scrollbars);};Dialog._open=function(url,action,init,width,height,_opener,editor,scrollbars){if(typeof(Dialog._modal)=="object"&&typeof(Dialog._modal.close)=="function"){Dialog._modal.close();Dialog._modal=null;}var dlg=window.open(url,'hadialog',"toolbar=no,location=no,directories=no,menubar=no,width="+width+",height="+height+",scrollbars="+scrollbars+",resizable=yes,modal=yes,dependent=yes,top=100,left=100");var obj=new Object();obj.dialogWindow=dlg;Dialog._dialog=obj;Dialog._modal=dlg;Dialog._arguments=null;if(typeof(init)!="undefined"){Dialog._arguments=init;}function capwin(w){if(HTMLArea.is_gecko){w.addEventListener("focus",function(ev){Dialog._parentEvent(ev);},false);}else{HTMLArea._addEvent(w,"focus",function(ev){Dialog._parentEvent(ev);});}for(var i=0;i<w.frames.length;i++){capwin(w.frames[i]);}}capwin(window);function closeDialog(){if(Dialog._dialog&&Dialog._dialog.dialogWindow){Dialog._dialog.dialogWindow.close();Dialog._dialog=null;}if(dlg&&!dlg.closed){dlg.close();dlg=null;}return false;}Dialog._return=function(val){if(val&&action){action(val);}function relwin(w){HTMLArea._removeEvent(w,"focus",function(ev){Dialog._parentEvent(ev);});try{for(var i=0;i<w.frames.length;i++){relwin(w.frames[i]);}}catch(e){}}relwin(window);HTMLArea._removeEvent(window,"unload",closeDialog);Dialog._dialog=null;};HTMLArea._addEvent(dlg,"unload",function(){if(typeof(Dialog)!="undefined")Dialog._return(null);return false;});HTMLArea._addEvent(window,"unload",closeDialog);};Dialog._parentEvent=function(ev){if(Dialog._modal&&!Dialog._modal.closed){if(!ev)var ev=window.event;var target=(ev.target)?ev.target:ev.srcElement;Dialog._modal.focus();HTMLArea._stopEvent(ev);}return false;};HTMLArea.prototype._popupDialog=function(url,action,init,width,height,_opener,scrollbars){if(typeof(_opener)=="undefined"||!_opener)var _opener=(this._iframe.contentWindow?this._iframe.contentWindow:window);if(typeof(scrollbars)=="undefined")var scrollbars="no";Dialog(this.popupURL(url),action,init,width,height,_opener,this,scrollbars);};HTMLArea.getElementById=function(tag,id){var el,i,objs=document.getElementsByTagName(tag);for(i=objs.length;--i>=0&&(el=objs[i]);){if(el.id==id)return el;}return null;};HTMLArea.edHidePopup=function(){Dialog._modal.close();setTimeout("if (typeof(browserWin) != 'undefined' && typeof(browserWin.focus) == 'function') browserWin.focus();",200);};var setRTEsizeByJS=function(divId,height,width){if(HTMLArea.is_gecko)height=height-25;else height=height-60;if(height>0)document.getElementById(divId).style.height=height+"px";if(HTMLArea.is_gecko)width="99%";else width="97%";document.getElementById(divId).style.width=width;};var lorem_ipsum=function(element,text){if(element.tagName.toLowerCase()=="textarea"&&element.id&&element.id.substr(0,7)=="RTEarea"){var editor=RTEarea[element.id.substr(7,8)]["editor"];editor.insertHTML(text);editor.updateToolbar();}};HTMLArea.initTimer=[];HTMLArea.onGenerateHandler=function(editorNumber){return(function(){document.getElementById('pleasewait'+editorNumber).style.display='none';document.getElementById('editorWrap'+editorNumber).style.visibility='visible';editorNumber=null;});};HTMLArea.initEditor=function(editorNumber){if(HTMLArea.checkSupportedBrowser()){document.getElementById('pleasewait'+editorNumber).style.display='block';document.getElementById('editorWrap'+editorNumber).style.visibility='hidden';if(HTMLArea.initTimer[editorNumber])window.clearTimeout(HTMLArea.initTimer[editorNumber]);if(!HTMLArea.is_loaded){HTMLArea.initTimer[editorNumber]=window.setTimeout("HTMLArea.initEditor("+editorNumber+");",150);}else{var RTE=RTEarea[editorNumber];var config=new HTMLArea.Config();config.toolbar=RTE["toolbar"];RTE["editor"]=new HTMLArea(RTE["id"],config);var editor=RTE["editor"];editor._typo3EditerNumber=editorNumber;editor._editorNumber=editorNumber;config=editor.config;config.buttons=RTE["buttons"];config.hideTableOperationsInToolbar=RTE["hideTableOperationsInToolbar"]?RTE["hideTableOperationsInToolbar"]:false;config.disableLayoutFieldsetInTableOperations=RTE["disableLayoutFieldsetInTableOperations"]?RTE["disableLayoutFieldsetInTableOperations"]:false;config.disableAlignmentFieldsetInTableOperations=RTE["disableAlignmentFieldsetInTableOperations"]?RTE["disableAlignmentFieldsetInTableOperations"]:false;config.disableSpacingFieldsetInTableOperations=RTE["disableSpacingFieldsetInTableOperations"]?RTE["disableSpacingFieldsetInTableOperations"]:false;config.disableBordersFieldsetInTableOperations=RTE["disableBordersFieldsetInTableOperations"]?RTE["disableBordersFieldsetInTableOperations"]:false;config.disableColorFieldsetInTableOperations=RTE["disableColorFieldsetInTableOperations"]?RTE["disableColorFieldsetInTableOperations"]:false;config.disablePCexamples=RTE["disablePCexamples"]?RTE["disablePCexamples"]:false;for(var plugin in RTE["plugin"]){if(RTE["plugin"][plugin]){editor.registerPlugin(plugin);}}if(RTE["defaultPageStyle"])config.defaultPageStyle=RTE["defaultPageStyle"];if(RTE["pageStyle"])config.pageStyle=RTE["pageStyle"];if(RTE["fontname"])config.FontName=RTE["fontname"];if(RTE["fontsize"])config.FontSize=RTE["fontsize"];if(RTE["colors"])config.colors=RTE["colors"];if(RTE["disableColorPicker"])config.disableColorPicker=RTE["disableColorPicker"];if(RTE["paragraphs"])config.FormatBlock=RTE["paragraphs"];config.width="auto";config.height="auto";config.sizeIncludesToolbar=true;config.fullPage=false;config.useHTTPS=RTE["useHTTPS"]?RTE["useHTTPS"]:false;config.disableEnterParagraphs=RTE["disableEnterParagraphs"]?RTE["disableEnterParagraphs"]:false;config.removeTrailingBR=RTE["removeTrailingBR"]?RTE["removeTrailingBR"]:false;config.keepButtonGroupTogether=(RTE["keepButtonGroupTogether"]&&HTMLArea.is_gecko&&!HTMLArea.is_wamcom&&!HTMLArea.is_opera)?RTE["keepButtonGroupTogether"]:false;config.useCSS=RTE["useCSS"]?RTE["useCSS"]:false;config.enableMozillaExtension=RTE["enableMozillaExtension"]?RTE["enableMozillaExtension"]:false;config.statusBar=RTE["statusBar"]?RTE["statusBar"]:false;config.cleanWordOnPaste=RTE["enableWordClean"]?true:false;config.htmlRemoveTags=RTE["htmlRemoveTags"]?RTE["htmlRemoveTags"]:null;config.htmlRemoveTagsAndContents=RTE["htmlRemoveTagsAndContents"]?RTE["htmlRemoveTagsAndContents"]:null;config.htmlRemoveComments=RTE["htmlRemoveComments"]?true:false;editor.onGenerate=HTMLArea.onGenerateHandler(editorNumber);editor.generate();return false;}}else{document.getElementById('pleasewait'+editorNumber).style.display='none';document.getElementById('editorWrap'+editorNumber).style.visibility='visible';}};
 
+if(typeof(_editor_url)=="string"){_editor_url=_editor_url.replace(/\x2f*$/,'/');}else{alert("WARNING: _editor_url is not set!");var _editor_url='';}
+if(typeof(_editor_skin)=="string")_editor_skin=_editor_skin.replace(/\x2f*$/,'/');else var _editor_skin=_editor_url+"skins/default/";if(typeof(_editor_CSS)!="string")var _editor_CSS=_editor_url+"skins/default/htmlarea.css";if(typeof(_editor_edited_content_CSS)!="string")var _editor_edited_content_CSS=_editor_skin+"htmlarea-edited-content.css";if(typeof(_editor_lang)=="string")_editor_lang=_editor_lang?_editor_lang.toLowerCase():"en";var HTMLArea=function(textarea,config){if(HTMLArea.checkSupportedBrowser()){if(typeof(config)=="undefined")this.config=new HTMLArea.Config();else this.config=config;this._htmlArea=null;this._textArea=textarea;this._editMode="wysiwyg";this.plugins={};this._timerToolbar=null;this._undoQueue=new Array();this._undoPos=-1;this._customUndo=true;this.doctype='';this.eventHandlers={};}};HTMLArea.agt=navigator.userAgent.toLowerCase();HTMLArea.is_opera=(HTMLArea.agt.indexOf("opera")!=-1);HTMLArea.is_ie=(HTMLArea.agt.indexOf("msie")!=-1)&&!HTMLArea.is_opera;HTMLArea.is_safari=(HTMLArea.agt.indexOf("webkit")!=-1);HTMLArea.is_gecko=(navigator.product=="Gecko")||HTMLArea.is_opera;HTMLArea.is_wamcom=(HTMLArea.agt.indexOf("wamcom")!=-1)||(HTMLArea.is_gecko&&(HTMLArea.agt.indexOf("1.3")!=-1));HTMLArea._debugMode=false;if(typeof(_editor_debug_mode)!="undefined")HTMLArea._debugMode=_editor_debug_mode;HTMLArea._appendToLog=function(str){if(HTMLArea._debugMode){var log=document.getElementById("HTMLAreaLog");if(log){log.appendChild(document.createTextNode(str));log.appendChild(document.createElement("br"));}}};HTMLArea._compressedScripts=false;if(typeof(_editor_compressed_scripts)!="undefined")HTMLArea._compressedScripts=_editor_compressed_scripts;HTMLArea.I18N=HTMLArea_langArray;HTMLArea.is_loaded=false;HTMLArea.onload=function(){HTMLArea.is_loaded=true;HTMLArea._appendToLog("All scripts successfully loaded.");};HTMLArea.loadTimer;HTMLArea._scripts=[];HTMLArea._scriptLoaded=[];HTMLArea._request=[];HTMLArea.loadScript=function(url,plugin){if(plugin)url=_editor_url+"/plugins/"+plugin+'/'+url;if(HTMLArea.is_opera)url=_typo3_host_url+url;if(HTMLArea._compressedScripts&&url.indexOf("compressed")==-1)url=url.replace(/\.js$/gi,"-compressed.js");HTMLArea._scripts.push(url);};HTMLArea.loadScript(RTEarea[0]["popupwin"]?RTEarea[0]["popupwin"]:_editor_url+"popupwin.js");if(HTMLArea.is_gecko)HTMLArea.loadScript(RTEarea[0]["htmlarea-gecko"]?RTEarea[0]["htmlarea-gecko"]:_editor_url+"htmlarea-gecko.js");if(HTMLArea.is_ie)HTMLArea.loadScript(RTEarea[0]["htmlarea-ie"]?RTEarea[0]["htmlarea-ie"]:_editor_url+"htmlarea-ie.js");HTMLArea.MSXML_XMLHTTP_PROGIDS=new Array("Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP");HTMLArea.XMLHTTPResponseHandler=function(i){return(function(){var url=HTMLArea._scripts[i];if(HTMLArea._request[i].readyState!=4)return;if(HTMLArea._request[i].status==200){try{eval(HTMLArea._request[i].responseText);HTMLArea._scriptLoaded[i]=true;i=null;}catch(e){HTMLArea._appendToLog("ERROR [HTMLArea::getScript]: Unable to get script "+url+": "+e);}}else{HTMLArea._appendToLog("ERROR [HTMLArea::getScript]: Unable to get "+url+" . Server reported "+HTMLArea._request[i].status);}});};HTMLArea._getScript=function(i,asynchronous,url){if(typeof(url)=="undefined")var url=HTMLArea._scripts[i];if(typeof(asynchronous)=="undefined")var asynchronous=true;if(window.XMLHttpRequest)HTMLArea._request[i]=new XMLHttpRequest();else if(window.ActiveXObject){var success=false;for(var k=0;k<HTMLArea.MSXML_XMLHTTP_PROGIDS.length&&!success;k++){try{HTMLArea._request[i]=new ActiveXObject(HTMLArea.MSXML_XMLHTTP_PROGIDS[k]);success=true;}catch(e){}}
+if(!success)return false;}
+var request=HTMLArea._request[i];if(request){request.open("GET",url,asynchronous);if(asynchronous)request.onreadystatechange=HTMLArea.XMLHTTPResponseHandler(i);if(window.XMLHttpRequest)request.send(null);else if(window.ActiveXObject)request.send();if(!asynchronous){if(request.status==200)return request.responseText;else return'';}
+return true;}else{return false;}};HTMLArea.checkInitialLoad=function(){var scriptsLoaded=true;for(var i=HTMLArea._scripts.length;--i>=0;){scriptsLoaded=scriptsLoaded&&HTMLArea._scriptLoaded[i];}
+if(HTMLArea.loadTimer)window.clearTimeout(HTMLArea.loadTimer);if(scriptsLoaded){HTMLArea.is_loaded=true;HTMLArea._appendToLog("[HTMLArea::init]: All scripts successfully loaded.");HTMLArea._appendToLog("[HTMLArea::init]: Editor url set to: "+_editor_url);HTMLArea._appendToLog("[HTMLArea::init]: Editor skin CSS set to: "+_editor_CSS);HTMLArea._appendToLog("[HTMLArea::init]: Editor content skin CSS set to: "+_editor_edited_content_CSS);if(window.ActiveXObject){for(var i=HTMLArea._scripts.length;--i>=0;){HTMLArea._request[i].onreadystatechange=new Function();HTMLArea._request[i]=null;}}}else{HTMLArea.loadTimer=window.setTimeout("HTMLArea.checkInitialLoad();",200);return false;}};HTMLArea.init=function(){HTMLArea._eventCache=HTMLArea._eventCacheConstructor();if(window.XMLHttpRequest||window.ActiveXObject){try{var success=true;for(var i=HTMLArea._scripts.length;--i>=0&&success;)success=success&&HTMLArea._getScript(i);}catch(e){HTMLArea._appendToLog("ERROR [HTMLArea::init]: Unable to use XMLHttpRequest: "+e);}
+if(success){HTMLArea.checkInitialLoad();}else{if(HTMLArea.is_ie)window.setTimeout('if (window.document.getElementById("pleasewait1")) { window.document.getElementById("pleasewait1").innerHTML = HTMLArea.I18N.msg["ActiveX-required"]; } else { alert(HTMLArea.I18N.msg["ActiveX-required"]); };',200);}}else{if(HTMLArea.is_ie)alert(HTMLArea.I18N.msg["ActiveX-required"]);}};HTMLArea.RE_tagName=/(<\/|<)\s*([^ \t\n>]+)/ig;HTMLArea.RE_doctype=/(<!doctype((.|\n)*?)>)\n?/i;HTMLArea.RE_head=/<head>((.|\n)*?)<\/head>/i;HTMLArea.RE_body=/<body>((.|\n)*?)<\/body>/i;HTMLArea.Reg_body=new RegExp("<\/?(body)[^>]*>","gi");HTMLArea.Reg_entities=new RegExp("&amp;([0-9]+);","gi");HTMLArea.reservedClassNames=/htmlarea/;HTMLArea.RE_email=/([0-9a-z]+([a-z0-9_-]*[0-9a-z])*){1}(\.[0-9a-z]+([a-z0-9_-]*[0-9a-z])*)*@([0-9a-z]+([a-z0-9_-]*[0-9a-z])*\.)+[a-z]{2,9}/i;HTMLArea.RE_url=/(https?:\/\/)?(([a-z0-9_]+:[a-z0-9_]+@)?[a-z0-9_-]{2,}(\.[a-z0-9_-]{2,})+\.[a-z]{2,5}(:[0-9]+)?(\/\S+)*)/i;HTMLArea.Config=function(){this.version="3.0";this.width="auto";this.height="auto";this.statusBar=true;this.undoSteps=20;this.undoTimeout=500;this.sizeIncludesToolbar=true;this.fullPage=false;this.useHTTPS=false;this.useCSS=false;this.enableMozillaExtension=true;this.disableEnterParagraphs=false;this.removeTrailingBR=false;this.editedContentStyle=_editor_edited_content_CSS;this.pageStyle="";this.cleanWordOnPaste=true;this.makeLinkShowsTarget=true;this.htmlRemoveTags=null;this.htmlRemoveTagsAndContents=null;this.htmlRemoveComments=false;this.customTags=null;this.baseURL=document.baseURI||document.URL;if(this.baseURL&&this.baseURL.match(/(.*)\/([^\/]+)/))this.baseURL=RegExp.$1+"/";this.imgURL="images/";this.popupURL="popups/";this.btnList={Bold:["Bold","ed_format_bold",false,function(editor){editor.execCommand("Bold");}],Italic:["Italic","ed_format_italic",false,function(editor){editor.execCommand("Italic");}],Underline:["Underline","ed_format_underline",false,function(editor){editor.execCommand("Underline");}],StrikeThrough:["Strikethrough","ed_format_strike",false,function(editor){editor.execCommand("StrikeThrough");}],Subscript:["Subscript","ed_format_sub",false,function(editor){editor.execCommand("Subscript");}],Superscript:["Superscript","ed_format_sup",false,function(editor){editor.execCommand("Superscript");}],JustifyLeft:["Justify Left","ed_align_left.gif",false,function(editor){editor.execCommand("JustifyLeft");}],JustifyCenter:["Justify Center","ed_align_center.gif",false,function(editor){editor.execCommand("JustifyCenter");}],JustifyRight:["Justify Right","ed_align_right.gif",false,function(editor){editor.execCommand("JustifyRight");}],JustifyFull:["Justify Full","ed_align_justify.gif",false,function(editor){editor.execCommand("JustifyFull");}],InsertOrderedList:["Ordered List","ed_list_num.gif",false,function(editor){editor.execCommand("InsertOrderedList");}],InsertUnorderedList:["Bulleted List","ed_list_bullet",false,function(editor){editor.execCommand("InsertUnorderedList");}],Outdent:["Decrease Indent","ed_indent_less.gif",false,function(editor){editor.execCommand("Outdent");}],Indent:["Increase Indent","ed_indent_more.gif",false,function(editor){editor.execCommand("Indent");}],ForeColor:["Font Color","ed_color_fg.gif",false,function(editor){editor.execCommand("ForeColor");}],HiliteColor:["Background Color","ed_color_bg.gif",false,function(editor){editor.execCommand("HiliteColor");}],InsertHorizontalRule:["Horizontal Rule","ed_hr.gif",false,function(editor){editor.execCommand("InsertHorizontalRule");}],CreateLink:["Insert Web Link","ed_link.gif",false,function(editor){editor.execCommand("CreateLink",true);},"a",false,true],InsertImage:["Insert/Modify Image","ed_image.gif",false,function(editor){editor.execCommand("InsertImage");}],InsertTable:["Insert Table","insert_table.gif",false,function(editor){editor.execCommand("InsertTable");}],HtmlMode:["Toggle HTML Source","ed_html.gif",true,function(editor){editor.execCommand("HtmlMode");}],SelectAll:["SelectAll","",true,function(editor){editor.execCommand("SelectAll");},null,true,false],SplitBlock:["Toggle Container Block","ed_splitblock.gif",false,function(editor){editor.execCommand("SplitBlock");}],About:["About this editor","ed_about.gif",true,function(editor){editor.execCommand("About");}],Undo:["Undoes your last action","ed_undo.gif",false,function(editor){editor.execCommand("Undo");}],Redo:["Redoes your last action","ed_redo.gif",false,function(editor){editor.execCommand("Redo");}],Cut:["Cut selection","ed_cut.gif",false,function(editor,command,obj){editor.execCommand("Cut");}],Copy:["Copy selection","ed_copy.gif",false,function(editor,command,obj){editor.execCommand("Copy");}],Paste:["Paste from clipboard","ed_paste.gif",false,function(editor,command,obj){editor.execCommand("Paste");}],SelectAll:["SelectAll","",true,function(editor){editor.execCommand("SelectAll");},null,true,false],LeftToRight:["Direction left to right","ed_left_to_right.gif",false,function(editor){editor.execCommand("LeftToRight");}],RightToLeft:["Direction right to left","ed_right_to_left.gif",false,function(editor){editor.execCommand("RightToLeft");}]};this.hotKeyList={a:"SelectAll",b:"Bold",i:"Italic",u:"Underline",s:"StrikeThrough",l:"JustifyLeft",e:"JustifyCenter",r:"JustifyRight",j:"JustifyFull",n:"FormatBlock",v:"Paste",0:"CleanWord",z:"Undo",y:"Redo"};for(var i in this.btnList){var btn=this.btnList[i];if(typeof(HTMLArea.I18N.tooltips[i.toLowerCase()])!="undefined")btn[0]=HTMLArea.I18N.tooltips[i.toLowerCase()];if(typeof(btn[1])=="string")btn[1]=_editor_skin+this.imgURL+btn[1];else btn[1][0]=_editor_skin+this.imgURL+btn[1][0];}
+this.customSelects={};};HTMLArea.Config.prototype.registerButton=function(id,tooltip,image,textMode,action,context,hide,selection){var the_id;switch(typeof(id)){case"string":the_id=id;break;case"object":the_id=id.id;break;default:HTMLArea._appendToLog("ERROR [HTMLArea.Config::registerButton]: invalid arguments");return false;}
+if(typeof(this.customSelects[the_id])!="undefined")HTMLArea._appendToLog("WARNING [HTMLArea.Config::registerButton]: A dropdown with the same ID "+id+" already exists.");if(typeof(this.btnList[the_id])!="undefined")HTMLArea._appendToLog("WARNING [HTMLArea.Config::registerButton]: A button with the same ID "+id+" already exists.");switch(typeof(id)){case"string":if(typeof(hide)=="undefined")var hide=false;if(typeof(selection)=="undefined")var selection=false;this.btnList[id]=[tooltip,image,textMode,action,context,hide,selection];break;case"object":if(typeof(id.hide)=="undefined")id.hide=false;if(typeof(id.selection)=="undefined")id.selection=false;this.btnList[id.id]=[id.tooltip,id.image,id.textMode,id.action,id.context,id.hide,id.selection];break;}};HTMLArea.Config.prototype.registerDropdown=function(object){if(typeof(this.customSelects[object.id])!="undefined")HTMLArea._appendToLog("WARNING [HTMLArea.Config::registerDropdown]: A dropdown with the same ID "+object.id+" already exists.");if(typeof(this.btnList[object.id])!="undefined")HTMLArea._appendToLog("WARNING [HTMLArea.Config::registerDropdown]: A button with the same ID "+object.id+" already exists.");this.customSelects[object.id]=object;};HTMLArea.setButtonStatus=function(id,newval){var oldval=this[id];var el=document.getElementById(this.elementId);if(oldval!=newval){switch(id){case"enabled":if(newval){if(!HTMLArea.is_wamcom){HTMLArea._removeClass(el,"buttonDisabled");HTMLArea._removeClass(el.parentNode,"buttonDisabled");}
+el.disabled=false;}else{if(!HTMLArea.is_wamcom){HTMLArea._addClass(el,"buttonDisabled");HTMLArea._addClass(el.parentNode,"buttonDisabled");}
+el.disabled=true;}
+break;case"active":if(newval){HTMLArea._addClass(el,"buttonPressed");HTMLArea._addClass(el.parentNode,"buttonPressed");}else{HTMLArea._removeClass(el,"buttonPressed");HTMLArea._removeClass(el.parentNode,"buttonPressed");}
+break;}
+this[id]=newval;}};HTMLArea.newLine=function(toolbar){tb_line=document.createElement("ul");tb_line.className="tb-line";toolbar.appendChild(tb_line);return tb_line;};HTMLArea.addTbElement=function(element,tb_line,first_cell_on_line){var tb_cell=document.createElement("li");if(first_cell_on_line)tb_cell.className="tb-first-cell";else tb_cell.className="tb-cell";HTMLArea._addClass(tb_cell,element.className);tb_line.appendChild(tb_cell);tb_cell.appendChild(element);if(element.style.display=="none"){tb_cell.style.display="none";if(HTMLArea._hasClass(tb_line,"tb-group"))tb_line.style.display="none";if(HTMLArea._hasClass(tb_cell.previousSibling,"separator"))tb_cell.previousSibling.style.display="none";}
+return false;};HTMLArea.addTbGroup=function(tb_line,first_cell_on_line){var tb_group=document.createElement("ul");tb_group.className="tb-group";HTMLArea.addTbElement(tb_group,tb_line,first_cell_on_line);return tb_group;};HTMLArea.prototype.createSelect=function(txt,tb_line,first_cell_on_line,labelObj){var options=null,cmd=null,context=null,tooltip="",newObj={created:false,el:null,first:first_cell_on_line,labelUsed:false};switch(txt){case"FontSize":case"FontName":case"FormatBlock":options=this.config[txt];tooltip=HTMLArea.I18N.tooltips[txt.toLowerCase()];cmd=txt;break;default:cmd=txt;var dropdown=this.config.customSelects[cmd];if(typeof(dropdown)!="undefined"){options=dropdown.options;context=dropdown.context;if(typeof(dropdown.tooltip)!="undefined")tooltip=dropdown.tooltip;}
+break;}
+if(options){newObj["el"]=document.createElement("select");newObj["el"].className="select";newObj["el"].title=tooltip;newObj["el"].id=this._editorNumber+"-"+txt;newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);var obj={name:txt,elementId:newObj["el"].id,enabled:true,text:false,cmd:cmd,state:HTMLArea.setButtonStatus,context:context,editorNumber:this._editorNumber};this._toolbarObjects[txt]=obj;newObj["el"]._obj=obj;if(labelObj["labelRef"]){labelObj["el"].htmlFor=newObj["el"].id;newObj["labelUsed"]=true;}
+HTMLArea._addEvent(newObj["el"],"change",HTMLArea.toolBarButtonHandler);for(var i in options){var op=document.createElement("option");op.innerHTML=i;op.value=options[i];if(txt=="FontName"&&!this.config.disablePCexamples){if(HTMLArea.is_gecko)op.setAttribute("style","font-family:"+op.value+";");else op.style.cssText="font-family:"+op.value+";";}
+newObj["el"].appendChild(op);}
+newObj["created"]=true;}
+return newObj;};HTMLArea.prototype.createButton=function(txt,tb_line,first_cell_on_line,labelObj){var btn=null,btnImg=null,newObj={created:false,el:null,first:first_cell_on_line,labelUsed:false};switch(txt){case"separator":newObj["el"]=document.createElement("div");newObj["el"].className="separator";newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);newObj["created"]=true;break;case"space":newObj["el"]=document.createElement("div");newObj["el"].className="space";newObj["el"].innerHTML="&nbsp;";newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);newObj["created"]=true;break;case"TextIndicator":newObj["el"]=document.createElement("div");newObj["el"].appendChild(document.createTextNode("A"));newObj["el"].className="indicator";newObj["el"].title=HTMLArea.I18N.tooltips.textindicator;newObj["el"].id=this._editorNumber+"-"+txt;newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);var obj={name:txt,elementId:newObj["el"].id,enabled:true,active:false,text:false,cmd:"TextIndicator",state:HTMLArea.setButtonStatus};this._toolbarObjects[txt]=obj;newObj["created"]=true;break;default:btn=this.config.btnList[txt];}
+if(!newObj["created"]&&btn){newObj["el"]=document.createElement("button");newObj["el"].title=btn[0];newObj["el"].className="button";newObj["el"].id=this._editorNumber+"-"+txt;if(btn[5])newObj["el"].style.display="none";newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);var obj={name:txt,elementId:newObj["el"].id,enabled:true,active:false,text:btn[2],cmd:btn[3],state:HTMLArea.setButtonStatus,context:btn[4]||null,selection:btn[6],editorNumber:this._editorNumber};this._toolbarObjects[txt]=obj;newObj["el"]._obj=obj;if(labelObj["labelRef"]){labelObj["el"].htmlFor=newObj["el"].id;newObj["labelUsed"]=true;}
+HTMLArea._addEvents(newObj["el"],["mouseover","mouseout","mousedown","click"],HTMLArea.toolBarButtonHandler);if(typeof(btn[1])!="string"&&HTMLArea.is_ie){var btnImgContainer=document.createElement("div");btnImgContainer.className="buttonImgContainer";btnImgContainer.innerHTML='<img src="'+btn[1][0]+'" style="position: relative; top: -'+(18*(btn[1][1]+1))+'px; left: -'+(18*(btn[1][2]+1))+'px;" alt="'+btn[0]+'" />';newObj["el"].appendChild(btnImgContainer);}else{newObj["el"].className+=" "+txt;if(this.plugins["TYPO3Browsers"]&&(txt=="CreateLink"||txt=="InsertImage"))newObj["el"].className+="-TYPO3Browsers";}
+newObj["created"]=true;}
+return newObj;};HTMLArea.createLabel=function(txt,tb_line,first_cell_on_line){var newObj={created:false,el:null,labelRef:false,first:first_cell_on_line};if(/^([IT])\[(.*?)\]/.test(txt)){var l7ed=RegExp.$1=="I";var label=RegExp.$2;if(l7ed)label=HTMLArea.I18N.dialogs[label];newObj["el"]=document.createElement("label");newObj["el"].className="label";newObj["el"].innerHTML=label;newObj["labelRef"]=true;newObj["created"]=true;newObj["first"]=HTMLArea.addTbElement(newObj["el"],tb_line,first_cell_on_line);}
+return newObj;};HTMLArea.prototype._createToolbar=function(){var j,k,code,n=this.config.toolbar.length,m,tb_line=null,tb_group=null,first_cell_on_line=true,labelObj=new Object(),tbObj=new Object();var toolbar=document.createElement("div");this._toolbar=toolbar;toolbar.className="toolbar";toolbar.unselectable="1";this._toolbarObjects=new Object();for(j=0;j<n;++j){tb_line=HTMLArea.newLine(toolbar);if(!this.config.keepButtonGroupTogether)HTMLArea._addClass(tb_line,"free-float");first_cell_on_line=true;tb_group=null;var group=this.config.toolbar[j];m=group.length;for(k=0;k<m;++k){code=group[k];if(code=="linebreak"){tb_line=HTMLArea.newLine(toolbar);if(!this.config.keepButtonGroupTogether)HTMLArea._addClass(tb_line,"free-float");first_cell_on_line=true;tb_group=null;}else{if((code=="separator"||first_cell_on_line)&&this.config.keepButtonGroupTogether){tb_group=HTMLArea.addTbGroup(tb_line,first_cell_on_line);first_cell_on_line=false;}
+created=false;if(/^([IT])\[(.*?)\]/.test(code)){labelObj=HTMLArea.createLabel(code,(tb_group?tb_group:tb_line),first_cell_on_line);created=labelObj["created"];first_cell_on_line=labelObj["first"];}
+if(!created){tbObj=this.createButton(code,(tb_group?tb_group:tb_line),first_cell_on_line,labelObj);created=tbObj["created"];first_cell_on_line=tbObj["first"];if(tbObj["labelUsed"])labelObj["labelRef"]=false;}
+if(!created){tbObj=this.createSelect(code,(tb_group?tb_group:tb_line),first_cell_on_line,labelObj);created=tbObj["created"];first_cell_on_line=tbObj["first"];if(tbObj["labelUsed"])labelObj["labelRef"]=false;}
+if(!created)HTMLArea._appendToLog("ERROR [HTMLArea::createToolbar]: Unknown toolbar item: "+code);}}}
+tb_line=HTMLArea.newLine(toolbar);this._htmlArea.appendChild(toolbar);};HTMLArea.toolBarButtonHandler=function(ev){if(!ev)var ev=window.event;var target=(ev.target)?ev.target:ev.srcElement;while(target.tagName.toLowerCase()=="img"||target.tagName.toLowerCase()=="div")target=target.parentNode;var obj=target._obj;var editorNumber=obj["editorNumber"];var editor=RTEarea[editorNumber]["editor"];if(obj.enabled){switch(ev.type){case"mouseover":HTMLArea._addClass(target,"buttonHover");HTMLArea._addClass(target.parentNode,"buttonHover");break;case"mouseout":HTMLArea._removeClass(target,"buttonHover");HTMLArea._removeClass(target.parentNode,"buttonHover");HTMLArea._removeClass(target,"buttonActive");HTMLArea._removeClass(target.parentNode,"buttonActive");if(obj.active){HTMLArea._addClass(target,"buttonPressed");HTMLArea._addClass(target.parentNode,"buttonPressed");}
+break;case"mousedown":HTMLArea._addClass(target,"buttonActive");HTMLArea._addClass(target.parentNode,"buttonActive");HTMLArea._removeClass(target,"buttonPressed");HTMLArea._removeClass(target.parentNode,"buttonPressed");HTMLArea._stopEvent(ev);break;case"click":HTMLArea._removeClass(target,"buttonActive");HTMLArea._removeClass(target.parentNode,"buttonActive");HTMLArea._removeClass(target,"buttonHover");HTMLArea._removeClass(target.parentNode,"buttonHover");obj.cmd(editor,obj.name,obj);HTMLArea._stopEvent(ev);break;case"change":editor.focusEditor();var value=target.options[target.selectedIndex].value;switch(obj.name){case"FontName":case"FontSize":editor.execCommand(obj.name,false,value);break;case"FormatBlock":(HTMLArea.is_ie||HTMLArea.is_safari)&&(value="<"+value+">");editor.execCommand(obj.name,false,value);break;default:var dropdown=editor.config.customSelects[obj.name];if(typeof(dropdown)!="undefined")dropdown.action(editor);else HTMLArea._appendToLog("ERROR [HTMLArea::toolBarButtonHandler]: Combo box "+obj.name+" not registered.");}}}};HTMLArea.prototype._createStatusBar=function(){var statusBar=document.createElement("div");this._statusBar=statusBar;statusBar.className="statusBar";if(!this.config.statusBar)statusBar.style.display="none";var statusBarTree=document.createElement("span");this._statusBarTree=statusBarTree;statusBarTree.className="statusBarTree";statusBar.appendChild(statusBarTree);statusBarTree.appendChild(document.createTextNode(HTMLArea.I18N.msg["Path"]+": "));this._htmlArea.appendChild(statusBar);};HTMLArea.prototype.generate=function(){var textarea=this._textArea;if(typeof(textarea)=="string"){textarea=HTMLArea.getElementById("textarea",textarea);this._textArea=textarea;}
+textarea.style.display="none";var htmlarea=document.createElement("div");htmlarea.className="htmlarea";htmlarea.style.width=textarea.style.width;this._htmlArea=htmlarea;textarea.parentNode.insertBefore(htmlarea,textarea);if(textarea.form){var f=textarea.form;if(typeof(f.onreset)=="function"){var funcref=f.onreset;if(typeof(f.__msh_prevOnReset)=="undefined")f.__msh_prevOnReset=[];f.__msh_prevOnReset.push(funcref);}
+f._editorNumber=this._editorNumber;HTMLArea._addEvent(f,"reset",HTMLArea.resetHandler);}
+this._createToolbar();HTMLArea._appendToLog("[HTMLArea::generate]: Toolbar successfully created.");var iframe=document.createElement("iframe");if(HTMLArea.is_ie||HTMLArea.is_safari||HTMLArea.is_wamcom){iframe.setAttribute("src",_editor_url+"popups/blank.html");}else if(HTMLArea.is_opera){iframe.setAttribute("src",_typo3_host_url+_editor_url+"popups/blank.html");}else{iframe.setAttribute("src","javascript:void(0);");}
+iframe.className="editorIframe";if(!this.config.statusBar)iframe.className+=" noStatusBar";htmlarea.appendChild(iframe);this._iframe=iframe;this._createStatusBar();this.sizeIframe(2);HTMLArea._appendToLog("[HTMLArea::generate]: Editor iframe successfully created.");this.initIframe();return this;};HTMLArea.prototype.sizeIframe=function(diff){var i;var height=(this.config.height=="auto"?(this._textArea.style.height):this.config.height);var textareaHeight=height;var inlineObject=RTEarea[this._editorNumber].tceformsInlineObject;var parentElements=RTEarea[this._editorNumber].tceformsDynTabs.split(',');if(inlineObject)parentElements.push(inlineObject);var dimensions=this.accessParentElements(parentElements,'this.getDimensions()');if(height.indexOf("%")==-1){height=parseInt(height)-diff;if(this.config.sizeIncludesToolbar){this._initialToolbarOffsetHeight=dimensions.toolbar.height;height-=dimensions.toolbar.height;height-=dimensions.statusbar.height;}
+if(height<0)height=0;textareaHeight=(height-4);if(textareaHeight<0)textareaHeight=0;height+="px";textareaHeight+="px";}
+this._iframe.style.height=height;this._textArea.style.height=textareaHeight;var textareaWidth=(this.config.width=="auto"?this._textArea.style.width:this.config.width);var iframeWidth=textareaWidth;if(textareaWidth.indexOf("%")==-1){iframeWidth=parseInt(textareaWidth)+"px";textareaWidth=parseInt(textareaWidth)-diff;if(textareaWidth<0)textareaWidth=0;textareaWidth+='px';}
+this._iframe.style.width="100%";if(HTMLArea.is_opera)this._iframe.style.width=iframeWidth;this._textArea.style.width=textareaWidth;};HTMLArea.prototype.getDimensions=function(){return{toolbar:{width:this._toolbar.offsetWidth,height:this._toolbar.offsetHeight},statusbar:{width:this._statusBar.offsetWidth,height:this._statusBar.offsetHeight}};};HTMLArea.prototype.accessParentElements=function(parentElements,callbackFunc){var result={};if(parentElements.length){var currentElement=parentElements.pop();var elementStyle=document.getElementById(currentElement).style;var actionRequired=elementStyle.display=='none';if(actionRequired){var originalVisibility=elementStyle.visibility;var originalPosition=elementStyle.position;elementStyle.visibility='hidden';elementStyle.position='absolute';elementStyle.display='';}
+result=this.accessParentElements(parentElements,callbackFunc);if(actionRequired){elementStyle.display='none';elementStyle.position=originalPosition;elementStyle.visibility=originalVisibility;}}else{result=eval(callbackFunc);}
+return result;};HTMLArea.initIframe=function(editorNumber){var editor=RTEarea[editorNumber]["editor"];editor.initIframe();};HTMLArea.prototype.initIframe=function(){if(this._initIframeTimer)window.clearTimeout(this._initIframeTimer);if(!this._iframe||(!this._iframe.contentWindow&&!this._iframe.contentDocument)){this._initIframeTimer=window.setTimeout("HTMLArea.initIframe("+this._editorNumber+");",50);return false;}else if(this._iframe.contentWindow){if(!this._iframe.contentWindow.document||!this._iframe.contentWindow.document.documentElement){this._initIframeTimer=window.setTimeout("HTMLArea.initIframe("+this._editorNumber+");",50);return false;}}else if(!this._iframe.contentDocument.documentElement){this._initIframeTimer=window.setTimeout("HTMLArea.initIframe("+this._editorNumber+");",50);return false;}
+var doc=this._iframe.contentWindow?this._iframe.contentWindow.document:this._iframe.contentDocument;this._doc=doc;if(!this.config.fullPage){var head=doc.getElementsByTagName("head")[0];if(!head){head=doc.createElement("head");doc.documentElement.appendChild(head);}
+if(this.config.baseURL&&!HTMLArea.is_opera){var base=doc.getElementsByTagName("base")[0];if(!base){base=doc.createElement("base");base.href=this.config.baseURL;head.appendChild(base);}
+HTMLArea._appendToLog("[HTMLArea::initIframe]: Iframe baseURL set to: "+this.config.baseURL);}
+var link0=doc.getElementsByTagName("link")[0];if(!link0){link0=doc.createElement("link");link0.rel="stylesheet";link0.href=this.config.editedContentStyle;head.appendChild(link0);HTMLArea._appendToLog("[HTMLArea::initIframe]: Skin CSS set to: "+this.config.editedContentStyle);}
+if(this.config.defaultPageStyle){var link=doc.getElementsByTagName("link")[1];if(!link){link=doc.createElement("link");link.rel="stylesheet";link.href=this.config.defaultPageStyle;head.appendChild(link);}
+HTMLArea._appendToLog("[HTMLArea::initIframe]: Override CSS set to: "+this.config.defaultPageStyle);}
+if(this.config.pageStyle){var link=doc.getElementsByTagName("link")[2];if(!link){link=doc.createElement("link");link.rel="stylesheet";link.href=this.config.pageStyle;head.appendChild(link);}
+HTMLArea._appendToLog("[HTMLArea::initIframe]: Content CSS set to: "+this.config.pageStyle);}}else{var html=this._textArea.value;this.setFullHTML(html);}
+HTMLArea._appendToLog("[HTMLArea::initIframe]: Editor iframe head successfully initialized.");this.stylesLoaded();};HTMLArea.stylesLoaded=function(editorNumber){var editor=RTEarea[editorNumber]["editor"];editor.stylesLoaded();};HTMLArea.prototype.stylesLoaded=function(){var doc=this._doc;var docWellFormed=true;if(this._stylesLoadedTimer)window.clearTimeout(this._stylesLoadedTimer);var stylesAreLoaded=true;var errorText='';var rules;for(var rule=0;rule<doc.styleSheets.length;rule++){if(HTMLArea.is_gecko)try{rules=doc.styleSheets[rule].cssRules;}catch(e){stylesAreLoaded=false;errorText=e;}
+if(HTMLArea.is_ie)try{rules=doc.styleSheets[rule].rules;}catch(e){stylesAreLoaded=false;errorText=e;}
+if(HTMLArea.is_ie)try{rules=doc.styleSheets[rule].imports;}catch(e){stylesAreLoaded=false;errorText=e;}}
+if(!stylesAreLoaded&&!HTMLArea.is_wamcom){HTMLArea._appendToLog("[HTMLArea::initIframe]: Failed attempt at loading stylesheets: "+errorText+" Retrying...");this._stylesLoadedTimer=window.setTimeout("HTMLArea.stylesLoaded("+this._editorNumber+");",100);return false;}
+HTMLArea._appendToLog("[HTMLArea::initIframe]: Stylesheets successfully loaded.");if(!this.config.fullPage){doc.body.style.borderWidth="0px";doc.body.className="htmlarea-content-body";try{doc.body.innerHTML=this._textArea.value;}catch(e){HTMLArea._appendToLog("[HTMLArea::initIframe]: The HTML document is not well-formed.");alert(HTMLArea.I18N.msg["HTML-document-not-well-formed"]);docWellFormed=false;}}
+if(this._customUndo)this._timerUndo=window.setInterval("HTMLArea.undoTakeSnapshot("+this._editorNumber+");",this.config.undoTimeout);if(docWellFormed){if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera&&!this._initEditMode())return false;if(HTMLArea.is_opera)doc.designMode="on";if(HTMLArea.is_ie||HTMLArea.is_safari)doc.body.contentEditable=true;if(HTMLArea.is_ie)doc.selection.empty();this._editMode="wysiwyg";if(doc.body.contentEditable||doc.designMode=="on")HTMLArea._appendToLog("[HTMLArea::initIframe]: Design mode successfully set.");}else{this._editMode="textmode";this.setMode("docnotwellformedmode");HTMLArea._appendToLog("[HTMLArea::initIframe]: Design mode could not be set.");}
+doc._editorNo=this._editorNumber;if(HTMLArea.is_ie)doc.documentElement._editorNo=this._editorNumber;HTMLArea._addEvents((HTMLArea.is_ie?doc.body:doc),["keydown","keypress","mousedown","mouseup","drag"],HTMLArea._editorEvent,true);HTMLArea._addEvent((this._iframe.contentWindow?this._iframe.contentWindow:this._iframe.contentDocument),"unload",HTMLArea.removeEditorEvents);if(this.config.cleanWordOnPaste)HTMLArea._addEvents((HTMLArea.is_ie?doc.body:doc),["paste","dragdrop","drop"],HTMLArea.cleanWordOnPaste,true);window.setTimeout("HTMLArea.generatePlugins("+this._editorNumber+");",100);};HTMLArea.generatePlugins=function(editorNumber){var editor=RTEarea[editorNumber]["editor"];editor._hasPluginWithOnKeyPressHandler=false;for(var i in editor.plugins){var plugin=editor.plugins[i].instance;if(typeof(plugin.onGenerate)=="function")plugin.onGenerate();if(typeof(plugin.onGenerateOnce)=="function"){plugin.onGenerateOnce();plugin.onGenerateOnce=null;}
+if(typeof(plugin.onKeyPress)=="function"){editor._hasPluginWithOnKeyPressHandler=true;}}
+if(typeof(editor.onGenerate)=="function"){editor.onGenerate();editor.onGenerate=null;}
+HTMLArea._appendToLog("[HTMLArea::initIframe]: All plugins successfully generated.");editor.updateToolbar();};HTMLArea.resetHandler=function(ev){if(!ev)var ev=window.event;var form=(ev.target)?ev.target:ev.srcElement;var editor=RTEarea[form._editorNumber]["editor"];editor.setHTML(editor._textArea.value);editor.updateToolbar();var a=form.__msh_prevOnReset;if(typeof(a)!="undefined"){for(var i=a.length;--i>=0;){a[i]();}}};HTMLArea.removeEditorEvents=function(ev){if(!ev)var ev=window.event;HTMLArea._stopEvent(ev);if(Dialog._modal){Dialog._modal.close();Dialog._modal=null;}
+for(var ed=RTEarea.length;--ed>0;){var editor=RTEarea[ed]["editor"];if(editor){RTEarea[ed]["editor"]=null;editor._textArea.value=editor.getHTML();window.clearInterval(editor._timerUndo);editor._undoQueue=null;if(HTMLArea._eventCache&&!HTMLArea.is_opera)HTMLArea._eventCache.flush();if(HTMLArea.is_ie)HTMLArea._cleanup(editor);}}};HTMLArea.prototype.setMode=function(mode){if(typeof(mode)=="undefined")var mode=(this._editMode=="textmode")?"wysiwyg":"textmode";switch(mode){case"textmode":case"docnotwellformedmode":this._textArea.value=this.getHTML();this._iframe.style.display="none";this._textArea.style.display="block";if(this.config.statusBar){var statusBarTextMode=document.createElement("span");statusBarTextMode.className="statusBarTextMode";statusBarTextMode.appendChild(document.createTextNode(HTMLArea.I18N.msg["TEXT_MODE"]));this._statusBar.innerHTML='';this._statusBar.appendChild(statusBarTextMode);}
+this._editMode="textmode";break;case"wysiwyg":if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera)this._doc.designMode="off";try{if(!this.config.fullPage)this._doc.body.innerHTML=this.getHTML();else this.setFullHTML(this.getHTML());}catch(e){alert(HTMLArea.I18N.msg["HTML-document-not-well-formed"]);break;}
+this._textArea.style.display="none";this._iframe.style.display="block";if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera)this._doc.designMode="on";if(this.config.statusBar){this._statusBar.innerHTML="";this._statusBar.appendChild(this._statusBarTree);}
+this._editMode="wysiwyg";break;default:return false;}
+if(!(mode=="docnotwellformedmode"))this.focusEditor();for(var i in this.plugins){var plugin=this.plugins[i].instance;if(typeof(plugin.onMode)=="function"){plugin.onMode(mode);}}};HTMLArea.prototype.setFullHTML=function(html){var save_multiline=RegExp.multiline;RegExp.multiline=true;if(html.match(HTMLArea.RE_doctype)){this.setDoctype(RegExp.$1);html=html.replace(HTMLArea.RE_doctype,"");};RegExp.multiline=save_multiline;if(!HTMLArea.is_ie){if(html.match(HTMLArea.RE_head))this._doc.getElementsByTagName("head")[0].innerHTML=RegExp.$1;if(html.match(HTMLArea.RE_body))this._doc.getElementsByTagName("body")[0].innerHTML=RegExp.$1;}else{var html_re=/<html>((.|\n)*?)<\/html>/i;html=html.replace(html_re,"$1");this._doc.open();this._doc.write(html);this._doc.close();this._doc.body.contentEditable=true;return true;};};HTMLArea.prototype.registerPlugin=function(){var plugin=arguments[0];var args=[];for(var i=1;i<arguments.length;++i){args.push(arguments[i]);}
+this.registerPlugin2(plugin,args);};HTMLArea.prototype.registerPlugin2=function(plugin,args){if(typeof(plugin)=="string"){var plugin=eval(plugin);};if(typeof(plugin)=="undefined"){HTMLArea._appendToLog("ERROR [HTMLArea::registerPlugin]: Can't register undefined plugin.");return false;};var obj=new plugin(this,args);if(obj){var clone={};var info=plugin._pluginInfo;for(var i in info){clone[i]=info[i];}
+clone.instance=obj;clone.args=args;this.plugins[plugin._pluginInfo.name]=clone;}else{HTMLArea._appendToLog("ERROR [HTMLArea::registerPlugin]: Can't register plugin "+plugin.toString()+".");};};HTMLArea.loadPlugin=function(pluginName,noLangFile,url){if(typeof(url)=="undefined"){var dir=_editor_url+"plugins/"+pluginName;var plugin=pluginName.replace(/([a-z])([A-Z])([a-z])/g,"$1"+"-"+"$2"+"$3").toLowerCase()+".js";var plugin_file=dir+"/"+plugin;HTMLArea.loadScript(plugin_file);if(typeof(noLangFile)=="undefined"||!noLangFile){var plugin_lang=dir+"/lang/"+_editor_lang+".js";HTMLArea._scripts.push(plugin_lang);}}else{HTMLArea.loadScript(url);}};HTMLArea.loadStyle=function(style,plugin,url){if(typeof(url)=="undefined"){var url=_editor_url||'';if(typeof(plugin)!="undefined"){url+="plugins/"+plugin+"/";}
+url+=style;if(/^\//.test(style)){url=style;}}
+var head=document.getElementsByTagName("head")[0];var link=document.createElement("link");link.rel="stylesheet";link.href=url;head.appendChild(link);};HTMLArea.loadStyle('','',_editor_CSS);HTMLArea.prototype.imgURL=function(file,plugin){if(typeof(plugin)=="undefined")return _editor_skin+this.config.imgURL+file;else return _editor_skin+this.config.imgURL+plugin+"/"+file;};HTMLArea.prototype.popupURL=function(file){var url="";if(file.match(/^plugin:\/\/(.*?)\/(.*)/)){var plugin=RegExp.$1;var popup=RegExp.$2;if(!/\.html$/.test(popup))popup+=".html";url=_editor_url+"plugins/"+plugin+"/popups/"+popup;}else{url=_typo3_host_url+_editor_url+this.config.popupURL+file;}
+return url;};HTMLArea.getInnerText=function(el){var txt='',i;for(i=el.firstChild;i;i=i.nextSibling){if(i.nodeType==3)txt+=i.data;else if(i.nodeType==1)txt+=HTMLArea.getInnerText(i);}
+return txt;};HTMLArea._wordClean=function(editor,html){function clearClass(node){var newc=node.className.replace(/(^|\s)mso.*?(\s|$)/ig,' ');if(newc!=node.className){node.className=newc;if(!/\S/.test(node.className))node.removeAttribute("className");}}
+function clearStyle(node){if(HTMLArea.is_ie)var style=node.style.cssText;else var style=node.getAttribute("style");if(style){var declarations=style.split(/\s*;\s*/);for(var i=declarations.length;--i>=0;){if(/^mso|^tab-stops/i.test(declarations[i])||/^margin\s*:\s*0..\s+0..\s+0../i.test(declarations[i]))declarations.splice(i,1);}
+node.setAttribute("style",declarations.join("; "));}}
+function stripTag(el){if(HTMLArea.is_ie){el.outerHTML=HTMLArea.htmlEncode(el.innerText);}else{var txt=document.createTextNode(HTMLArea.getInnerText(el));el.parentNode.insertBefore(txt,el);el.parentNode.removeChild(el);}}
+function checkEmpty(el){if(/^(span|b|strong|i|em|font)$/i.test(el.tagName)&&!el.firstChild)el.parentNode.removeChild(el);}
+function parseTree(root){var tag=root.tagName.toLowerCase(),i,next;if((HTMLArea.is_ie&&root.scopeName!='HTML')||(!HTMLArea.is_ie&&/:/.test(tag))||/o:p/.test(tag)){stripTag(root);return false;}else{clearClass(root);clearStyle(root);for(i=root.firstChild;i;i=next){next=i.nextSibling;if(i.nodeType==1&&parseTree(i)){checkEmpty(i);}}}
+return true;}
+parseTree(html);};HTMLArea.wordCleanLater=function(editorNumber,doUpdateToolbar){var editor=RTEarea[editorNumber]["editor"];HTMLArea._wordClean(editor,editor._doc.body);if(doUpdateToolbar)editor.updateToolbar();};HTMLArea.cleanWordOnPaste=function(ev){if(!ev)var ev=window.event;var target=(ev.target)?ev.target:ev.srcElement;var owner=(target.ownerDocument)?target.ownerDocument:target;while(HTMLArea.is_ie&&owner.parentElement){owner=owner.parentElement;}
+if(typeof(browserWin)!="undefined")browserWin.close();window.setTimeout("HTMLArea.wordCleanLater("+owner._editorNo+", true);",250);};HTMLArea.prototype.forceRedraw=function(){this._doc.body.style.visibility="hidden";this._doc.body.style.visibility="visible";};HTMLArea.prototype.focusEditor=function(){switch(this._editMode){case"wysiwyg":try{if(HTMLArea.is_safari||HTMLArea.is_opera)this._doc.focus();else this._iframe.contentWindow.focus();}catch(e){};break;case"textmode":this._textArea.focus();break;}
+return this._doc;};HTMLArea.undoTakeSnapshot=function(editorNumber){var editor=RTEarea[editorNumber]["editor"];if(editor._doc)editor._undoTakeSnapshot();};HTMLArea.prototype._undoTakeSnapshot=function(){var curTime=(new Date()).getTime();var newOne=true;if(this._undoPos>=this.config.undoSteps){this._undoQueue.shift();--this._undoPos;}
+if(this._undoPos<0||this._undoQueue[this._undoPos].time<curTime-this.config.undoTimeout){++this._undoPos;}else{newOne=false;}
+var txt=this.getInnerHTML();if(newOne){if(this._undoPos==0||this._undoQueue[this._undoPos-1].text!=txt){this._undoQueue[this._undoPos]={text:txt,time:curTime};this._undoQueue.length=this._undoPos+1;}else{this._undoPos--;}}else{if(this._undoQueue[this._undoPos].text!=txt){this._undoQueue[this._undoPos].text=txt;this._undoQueue.length=this._undoPos+1;}}};HTMLArea.setUndoQueueLater=function(editorNumber,op){var editor=RTEarea[editorNumber]["editor"];if(op=="undo"){editor.setHTML(editor._undoQueue[--editor._undoPos].text);}else if(op=="redo"){if(editor._undoPos<editor._undoQueue.length-1)editor.setHTML(editor._undoQueue[++editor._undoPos].text);}};HTMLArea.prototype.undo=function(){if(this._undoPos>0){this._undoTakeSnapshot();if(!HTMLArea.is_opera)this.setHTML(this._undoQueue[--this._undoPos].text);else window.setTimeout("HTMLArea.setUndoQueueLater("+this._editorNumber+", 'undo');",10);}};HTMLArea.prototype.redo=function(){if(this._undoPos<this._undoQueue.length-1){this._undoTakeSnapshot();if(!HTMLArea.is_opera){if(this._undoPos<this._undoQueue.length-1)this.setHTML(this._undoQueue[++this._undoPos].text);}else{window.setTimeout("HTMLArea.setUndoQueueLater("+this._editorNumber+", 'redo');",10);}}};HTMLArea.updateToolbar=function(editorNumber){var editor=RTEarea[editorNumber]["editor"];editor.updateToolbar();editor._timerToolbar=null;};HTMLArea.prototype.updateToolbar=function(noStatus){var doc=this._doc,text=(this._editMode=="textmode"),selection=this.hasSelectedText(),ancestors=null,cls=new Array(),txt,txtClass,i,cmd,inContext,match,matchAny,k,j,n,commandState;if(!text){ancestors=this.getAllAncestors();if(this.config.statusBar&&!noStatus){if(this._statusBarTree.hasChildNodes()){for(i=this._statusBarTree.firstChild;i;i=i.nextSibling){if(i.nodeName.toLowerCase()=="a"){HTMLArea._removeEvents(i,["click","contextmenu, mousedown"],HTMLArea.statusBarHandler);i.el=null;i.editor=null;}}}
+this._statusBarTree.innerHTML='';this._statusBarTree.appendChild(document.createTextNode(HTMLArea.I18N.msg["Path"]+": "));for(i=ancestors.length;--i>=0;){var el=ancestors[i];if(!el)continue;var a=document.createElement("a");a.href="#";a.el=el;a.editor=this;if(!HTMLArea.is_opera){HTMLArea._addEvents(a,["click","contextmenu"],HTMLArea.statusBarHandler);}else{HTMLArea._addEvents(a,["mousedown","click"],HTMLArea.statusBarHandler);}
+txt=el.tagName.toLowerCase();a.title=el.style.cssText;if(el.id){txt+="#"+el.id;}
+if(el.className){txtClass="";cls=el.className.trim().split(" ");for(j=cls.length;j>0;){if(!HTMLArea.reservedClassNames.test(cls[--j])){txtClass="."+cls[j];}}
+txt+=txtClass;}
+a.appendChild(document.createTextNode(txt));this._statusBarTree.appendChild(a);if(i!=0)this._statusBarTree.appendChild(document.createTextNode(String.fromCharCode(0xbb)));}}}
+for(i in this._toolbarObjects){var btn=this._toolbarObjects[i];cmd=i;inContext=true;if(btn.context&&!text){inContext=false;var attrs=[];var contexts=[];if(/(.*)\[(.*?)\]/.test(btn.context)){contexts=RegExp.$1.split(",");attrs=RegExp.$2.split(",");}else{contexts=btn.context.split(",");}
+for(j=contexts.length;--j>=0;)contexts[j]=contexts[j].toLowerCase();matchAny=(contexts[0]=="*");for(k=0;k<ancestors.length;++k){if(!ancestors[k])continue;match=false;for(j=contexts.length;--j>=0;)match=match||(ancestors[k].tagName.toLowerCase()==contexts[j]);if(matchAny||match){inContext=true;for(j=attrs.length;--j>=0;){if(!eval("ancestors[k]."+attrs[j])){inContext=false;break;}}
+if(inContext)break;}}}
+if(cmd=="CreateLink")btn.state("enabled",(!text||btn.text)&&(inContext||selection));else btn.state("enabled",(!text||btn.text)&&inContext&&(selection||!btn.selection));if(typeof(cmd)=="function"){continue;};var dropdown=this.config.customSelects[cmd];if((!text||btn.text)&&(typeof(dropdown)!="undefined")){dropdown.refresh(this);continue;}
+switch(cmd){case"FontName":case"FontSize":if(!text)try{var value=(""+doc.queryCommandValue(cmd)).toLowerCase();if(!value){document.getElementById(btn.elementId).selectedIndex=0;break;}
+var options=this.config[cmd];k=0;for(j in options){if((j.toLowerCase()==value)||(options[j].substr(0,value.length).toLowerCase()==value)){document.getElementById(btn.elementId).selectedIndex=k;throw"ok";}
+++k;}
+document.getElementById(btn.elementId).selectedIndex=0;}catch(e){}
+break;case"FormatBlock":var blocks=[];for(var i in this.config['FormatBlock']){blocks[blocks.length]=this.config['FormatBlock'][i];}
+var deepestAncestor=this._getFirstAncestor(this._getSelection(),blocks);if(deepestAncestor){for(var x=0;x<blocks.length;x++){if(blocks[x].toLowerCase()==deepestAncestor.tagName.toLowerCase())document.getElementById(btn.elementId).selectedIndex=x;}}else{document.getElementById(btn.elementId).selectedIndex=0;}
+break;case"TextIndicator":if(!text){try{with(document.getElementById(btn.elementId).style){backgroundColor=HTMLArea._makeColor(doc.queryCommandValue((HTMLArea.is_ie||HTMLArea.is_safari)?"BackColor":"HiliteColor"));if(/transparent/i.test(backgroundColor)){backgroundColor=HTMLArea._makeColor(doc.queryCommandValue("BackColor"));}
+color=HTMLArea._makeColor(doc.queryCommandValue("ForeColor"));fontFamily=doc.queryCommandValue("FontName");fontWeight="normal";fontStyle="normal";try{fontWeight=doc.queryCommandState("Bold")?"bold":"normal";}catch(ex){fontWeight="normal";};try{fontStyle=doc.queryCommandState("Italic")?"italic":"normal";}catch(ex){fontStyle="normal";};}}catch(e){}}
+break;case"HtmlMode":btn.state("active",text);break;case"LeftToRight":case"RightToLeft":var el=this.getParentElement();while(el&&!HTMLArea.isBlockElement(el)){el=el.parentNode;}
+if(el)btn.state("active",(el.style.direction==((cmd=="RightToLeft")?"rtl":"ltr")));break;case"Bold":case"Italic":case"StrikeThrough":case"Underline":case"Subscript":case"Superscript":case"JustifyLeft":case"JustifyCenter":case"JustifyRight":case"JustifyFull":case"Indent":case"Outdent":case"InsertOrderedList":case"InsertUnorderedList":commandState=false;if(!text)try{commandState=doc.queryCommandState(cmd);}catch(e){commandState=false;}
+btn.state("active",commandState);break;default:break;}}
+if(this._customUndo)this._undoTakeSnapshot();for(i in this.plugins){var plugin=this.plugins[i].instance;if(typeof(plugin.onUpdateToolbar)=="function")plugin.onUpdateToolbar();}};HTMLArea.prototype.surroundHTML=function(startTag,endTag){this.insertHTML(startTag+this.getSelectedHTML().replace(HTMLArea.Reg_body,"")+endTag);};HTMLArea.prototype.convertNode=function(el,newTagName){var newel=this._doc.createElement(newTagName),p=el.parentNode;while(el.firstChild)newel.appendChild(el.firstChild);p.insertBefore(newel,el);p.removeChild(el);return newel;};HTMLArea.getElementObject=function(el,tagName){var oEl=el;while(oEl!=null&&oEl.nodeName.toLowerCase()!=tagName)oEl=oEl.parentNode;return oEl;};HTMLArea.prototype.makeNestedList=function(el){var previous,clone;for(var i=el.firstChild;i;i=i.nextSibling){if(/^li$/i.test(i.tagName)){for(var j=i.firstChild;j;j=j.nextSibling){if(/^(ol|ul)$/i.test(j.tagName))this.makeNestedList(j);}}else if(/^(ol|ul)$/i.test(i.tagName)){previous=i.previousSibling;var clone=i.cloneNode(true);if(!previous){previous=el.insertBefore(this._doc.createElement("li"),i);previous.appendChild(clone);}else{previous.appendChild(clone);}
+HTMLArea.removeFromParent(i);this.makeNestedList(el);break;}}};HTMLArea.prototype.hasSelectedText=function(){return this.getSelectedHTML()!="";};HTMLArea.prototype.getAllAncestors=function(){var p=this.getParentElement();var a=[];while(p&&(p.nodeType==1)&&(p.tagName.toLowerCase()!='body')){a.push(p);p=p.parentNode;}
+a.push(this._doc.body);return a;};HTMLArea.prototype._getFirstAncestor=function(sel,types){var prnt=this._activeElement(sel);if(prnt==null){try{prnt=(HTMLArea.is_ie?this._createRange(sel).parentElement():this._createRange(sel).commonAncestorContainer);}catch(e){return null;}}
+if(typeof(types)=='string')types=[types];while(prnt){if(prnt.nodeType==1){if(types==null)return prnt;for(var i=0;i<types.length;i++){if(prnt.tagName.toLowerCase()==types[i])return prnt;}
+if(prnt.tagName.toLowerCase()=='body')break;if(prnt.tagName.toLowerCase()=='table')break;}
+prnt=prnt.parentNode;}
+return null;};HTMLArea.createLinkDialog=function(editor,link){return(function(param){if(!param||typeof(param.f_href)=="undefined")return false;var a=link;if(!a){try{editor._doc.execCommand("CreateLink",false,param.f_href);a=editor.getParentElement();var sel=editor._getSelection();var range=editor._createRange(sel);if(!HTMLArea.is_ie){a=range.startContainer;if(!/^a$/i.test(a.tagName)){a=a.nextSibling;if(a==null)a=range.startContainer.parentNode;}}}catch(e){}}else{var href=param.f_href.trim();editor.selectNodeContents(a);if(href==""){editor._doc.execCommand("Unlink",false,null);editor.updateToolbar();return false;}
+else{a.href=href;}}
+if(!(a&&/^a$/i.test(a.tagName)))return false;if(typeof(param.f_target)!="undefined")a.target=param.f_target.trim();if(typeof(param.f_title)!="undefined")a.title=param.f_title.trim();editor.selectNodeContents(a);editor.updateToolbar();editor=null;link=null;});};HTMLArea.prototype._createLink=function(link){var outparam=null;this.focusEditor();if(typeof(link)=="undefined"){link=this.getParentElement();if(link){if(/^img$/i.test(link.tagName))link=link.parentNode;if(!/^a$/i.test(link.tagName))link=null;}}
+if(!link){var sel=this._getSelection();if(this._selectionEmpty(sel)){alert("You need to select some text before creating a link");return;}
+outparam={f_href:'',f_title:'',f_target:'',f_usetarget:this.config.makeLinkShowsTarget};}else{outparam={f_href:HTMLArea.is_ie?this.stripBaseURL(link.href):link.getAttribute("href"),f_title:link.title,f_target:link.target,f_usetarget:this.config.makeLinkShowsTarget};}
+var createLinkDialogFunctRef=HTMLArea.createLinkDialog(this,link);this._popupDialog("link.html",createLinkDialogFunctRef,outparam,450,145);};HTMLArea.insertImageDialog=function(editor,image){return(function(param){if(!param||typeof(param.f_url)=="undefined")return false;var img=image;if(!img){var sel=editor._getSelection();var range=editor._createRange(sel);editor._doc.execCommand("InsertImage",false,param.f_url);if(HTMLArea.is_ie){img=range.parentElement();if(img.tagName.toLowerCase()!="img")img=img.previousSibling;}else{var sel=editor._getSelection();var range=editor._createRange(sel);img=range.startContainer;if(HTMLArea.is_opera)img=img.parentNode;img=img.lastChild;while(img&&img.nodeName.toLowerCase()!="img")img=img.previousSibling;}}else{img.src=param.f_url;}
+for(var field in param){var value=param[field];switch(field){case"f_alt":img.alt=value;break;case"f_border":if(parseInt(value)){img.style.borderWidth=parseInt(value)+"px";img.style.borderStyle="solid";}else{img.style.borderWidth="";img.style.borderStyle="none";}
+break;case"f_align":img.style.verticalAlign=value;break;case"f_vert":if(parseInt(value)){img.style.marginTop=parseInt(value)+"px";img.style.marginBottom=parseInt(value)+"px";}else{img.style.marginTop="";img.style.marginBottom="";}
+break;case"f_horiz":if(parseInt(value)){img.style.marginLeft=parseInt(value)+"px";img.style.marginRight=parseInt(value)+"px";}else{img.style.marginLeft="";img.style.marginRight="";}
+break;case"f_float":if(HTMLArea.is_ie)img.style.styleFloat=value;else img.style.cssFloat=value;break;}}
+editor=null;image=null;});};HTMLArea.prototype._insertImage=function(image){var outparam=null;this.focusEditor();if(typeof(image)=="undefined"){var image=this.getParentElement();if(image&&!/^img$/i.test(image.tagName))image=null;}
+if(image)outparam={f_base:this.config.baseURL,f_url:image.getAttribute("src"),f_alt:image.alt,f_border:isNaN(parseInt(image.style.borderWidth))?"":parseInt(image.style.borderWidth),f_align:image.style.verticalAlign,f_vert:isNaN(parseInt(image.style.marginTop))?"":parseInt(image.style.marginTop),f_horiz:isNaN(parseInt(image.style.marginLeft))?"":parseInt(image.style.marginLeft),f_float:HTMLArea.is_ie?image.style.styleFloat:image.style.cssFloat};var insertImageDialogFunctRef=HTMLArea.insertImageDialog(this,image);this._popupDialog("insert_image.html",insertImageDialogFunctRef,outparam,580,460);};HTMLArea.insertTableDialog=function(editor,sel,range){return(function(param){if(!param)return false;var doc=editor._doc;var table=doc.createElement("table");for(var field in param){var value=param[field];if(!value)continue;switch(field){case"f_width":if(value!="")table.style.width=parseInt(value)+param["f_unit"];break;case"f_align":table.style.textAlign=value;break;case"f_border":if(value!=""){table.style.borderWidth=parseInt(value)+"px";table.style.borderStyle="solid";}
+break;case"f_spacing":if(value!="")table.cellSpacing=parseInt(value);break;case"f_padding":if(value!="")table.cellPadding=parseInt(value);break;case"f_float":if(HTMLArea.is_ie)table.style.styleFloat=((value!="not set")?value:"");else table.style.cssFloat=((value!="not set")?value:"");break;}}
+var cellwidth=0;if(param.f_fixed)cellwidth=Math.floor(100/parseInt(param.f_cols));var tbody=doc.createElement("tbody");table.appendChild(tbody);for(var i=param["f_rows"];i>0;i--){var tr=doc.createElement("tr");tbody.appendChild(tr);for(var j=param["f_cols"];j>0;j--){var td=doc.createElement("td");if(cellwidth)td.style.width=cellwidth+"%";if(HTMLArea.is_opera){td.innerHTML='&nbsp;';}
+tr.appendChild(td);}}
+editor.focusEditor();if(HTMLArea.is_ie)range.pasteHTML(table.outerHTML);else editor.insertNodeAtSelection(table);if(editor.config.buttons["toggleborders"]&&editor.config.buttons["toggleborders"]["setOnTableCreation"])editor.plugins["TableOperations"].instance.buttonPress(editor,"TO-toggle-borders");if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera)editor.setMode("wysiwyg");editor.updateToolbar();editor=null;sel=null;range=null;return true;});};HTMLArea.prototype._insertTable=function(){var sel=this._getSelection();var range=this._createRange(sel);this.focusEditor();var insertTableDialogFunctRef=HTMLArea.insertTableDialog(this,sel,range);this._popupDialog("insert_table.html",insertTableDialogFunctRef,this,520,230);};HTMLArea.selectColorDialog=function(editor,cmdID){return(function(color){if(color)editor._doc.execCommand(cmdID,false,"#"+color);});};HTMLArea.prototype.execCommand=function(cmdID,UI,param){this.focusEditor();if(HTMLArea.is_gecko){try{this._doc.execCommand("useCSS",false,!this.config.useCSS);}catch(e){};try{this._doc.execCommand("styleWithCSS",false,this.config.useCSS);}catch(e){};}
+switch(cmdID){case"HtmlMode":this.setMode();break;case"SplitBlock":this._doc.execCommand('FormatBlock',false,((HTMLArea.is_ie||HTMLArea.is_safari)?"<div>":"div"));break;case"HiliteColor":(HTMLArea.is_ie||HTMLArea.is_safari)&&(cmdID="BackColor");case"ForeColor":var colorDialogFunctRef=HTMLArea.selectColorDialog(this,cmdID);this._popupDialog("select_color.html",colorDialogFunctRef,HTMLArea._colorToRgb(this._doc.queryCommandValue(cmdID)),200,182);break;case"CreateLink":this._createLink();break;case"Undo":case"Redo":if(this._customUndo)this[cmdID.toLowerCase()]();else this._doc.execCommand(cmdID,UI,param);break;case"InsertTable":this._insertTable();break;case"InsertImage":this._insertImage();break;case"About":this._popupDialog("about.html",null,this,475,350);break;case"CleanWord":HTMLArea._wordClean(this,this._doc.body);break;case"Cut":case"Copy":case"Paste":try{this._doc.execCommand(cmdID,false,null);if(cmdID=="Paste"&&this.config.cleanWordOnPaste)HTMLArea._wordClean(this,this._doc.body);}catch(e){if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera)this._mozillaPasteException(cmdID,UI,param);}
+break;case"LeftToRight":case"RightToLeft":var dir=(cmdID=="RightToLeft")?"rtl":"ltr";var el=this.getParentElement();while(el&&!HTMLArea.isBlockElement(el))el=el.parentNode;if(el){if(el.style.direction==dir)el.style.direction="";else el.style.direction=dir;}
+break;case"Indent":var el=this.getParentElement();while(el&&(!HTMLArea.isBlockElement(el)||/^li$/i.test(el.nodeName)))el=el.parentNode;try{this._doc.execCommand(cmdID,UI,param);}
+catch(e){if(this.config.debug)alert(e+"\n\nby execCommand("+cmdID+");");}
+if(/^(ol|ul)$/i.test(el.nodeName)){this.makeNestedList(el);this.selectNodeContents(el);}
+break;case"FontSize":case"FontName":if(param){this._doc.execCommand(cmdID,UI,param);break;}else{var sel=this._getSelection();if(HTMLArea.is_gecko&&sel.isCollapsed){var fontNode=this._getFirstAncestor(sel,"font");if(fontNode!=null)this.selectNode(fontNode);}
+this._doc.execCommand("RemoveFormat",UI,null);if(HTMLArea.is_gecko&&fontNode!=null){sel=this._getSelection();var r=this._createRange(sel).cloneRange();r.collapse(false);if(HTMLArea.is_safari){sel.empty();sel.setBaseAndExtent(r.startContainer,r.startOffset,r.endContainer,r.endOffset);}else{sel.removeAllRanges();sel.addRange(r);}}}
+break;default:try{this._doc.execCommand(cmdID,UI,param);}
+catch(e){if(this.config.debug)alert(e+"\n\nby execCommand("+cmdID+");");}}
+this.updateToolbar();return false;};HTMLArea._editorEvent=function(ev){if(!ev)var ev=window.event;var target=(ev.target)?ev.target:ev.srcElement;var owner=(target.ownerDocument)?target.ownerDocument:target;if(HTMLArea.is_ie){while(owner.parentElement){owner=owner.parentElement;}}
+var editor=RTEarea[owner._editorNo]["editor"];var keyEvent=((HTMLArea.is_ie||HTMLArea.is_safari)&&ev.type=="keydown")||(!HTMLArea.is_ie&&ev.type=="keypress");editor.focusEditor();if(keyEvent){if(editor._hasPluginWithOnKeyPressHandler){for(var i in editor.plugins){var plugin=editor.plugins[i].instance;if(typeof(plugin.onKeyPress)=="function"){if(plugin.onKeyPress(ev))return false;}}}
+if(ev.ctrlKey){if(!ev.altKey){var key=String.fromCharCode((HTMLArea.is_ie||HTMLArea.is_safari||HTMLArea.is_opera)?ev.keyCode:ev.charCode).toLowerCase();if(HTMLArea.is_gecko&&ev.keyCode==32)key=String.fromCharCode(ev.keyCode).toLowerCase();var cmd=null;var value=null;switch(key){case'1':case'2':case'3':case'4':case'5':case'6':if(editor._toolbarObjects["FormatBlock"]){cmd="FormatBlock";value="h"+key;if(HTMLArea.is_ie||HTMLArea.is_safari)value="<"+value+">";}
+break;case' ':editor.insertHTML("&nbsp;");editor.updateToolbar();HTMLArea._stopEvent(ev);return false;default:if(editor.config.hotKeyList[key]){switch(editor.config.hotKeyList[key]){case"SelectAll":case"CleanWord":cmd=editor.config.hotKeyList[key];break;case"Paste":if(HTMLArea.is_ie||HTMLArea.is_safari){cmd=editor.config.hotKeyList[key];}else if(editor.config.cleanWordOnPaste){window.setTimeout("HTMLArea.wordCleanLater("+owner._editorNo+", false);",50);}
+break;default:if(editor._toolbarObjects[editor.config.hotKeyList[key]]){cmd=editor.config.hotKeyList[key];if(cmd=="FormatBlock")value=(HTMLArea.is_ie||HTMLArea.is_safari)?"<p>":"p";}}}}
+if(cmd){editor.execCommand(cmd,false,value);HTMLArea._stopEvent(ev);return false;}else{editor.updateToolbar();}}}else if(ev.altKey){if(editor.plugins['ContextMenu']&&editor.plugins['ContextMenu'].instance){var keys=editor.plugins['ContextMenu'].instance.keys;if(keys.length>0){var k;for(var i=keys.length;--i>=0;){k=keys[i];if(k[0].toLowerCase()==key){HTMLArea._stopEvent(ev);return false;}}}}}else if(keyEvent){if(HTMLArea.is_gecko)editor._detectURL(ev);switch(ev.keyCode){case 13:if(HTMLArea.is_gecko&&!ev.shiftKey&&!editor.config.disableEnterParagraphs){editor._checkInsertP();HTMLArea._stopEvent(ev);editor.updateToolbar();}
+break;case 8:case 46:if((HTMLArea.is_gecko&&!ev.shiftKey)||HTMLArea.is_ie){if(editor._checkBackspace())HTMLArea._stopEvent(ev);}
+if(editor._timerToolbar)window.clearTimeout(editor._timerToolbar);editor._timerToolbar=window.setTimeout("HTMLArea.updateToolbar("+editor._editorNumber+");",50);break;case 9:if(HTMLArea.is_gecko){editor.execCommand((ev.shiftKey?"Outdent":"Indent"),false,null);HTMLArea._stopEvent(ev);return false;}
+break;case 37:case 39:if(HTMLArea.is_ie){editor._timerToolbar=window.setTimeout("HTMLArea.updateToolbar("+editor._editorNumber+");",10);break;}}}}else{if(editor._timerToolbar)window.clearTimeout(editor._timerToolbar);if(ev.type=="mouseup")editor.updateToolbar();else editor._timerToolbar=window.setTimeout("HTMLArea.updateToolbar("+editor._editorNumber+");",50);}};HTMLArea.prototype.scrollToCaret=function(){var e=this.getParentElement(),w=this._iframe.contentWindow?this._iframe.contentWindow:window,h=w.innerHeight||w.height,d=this._doc,t=d.documentElement.scrollTop||d.body.scrollTop;if(typeof(h)=="undefined")return false;if(e.offsetTop>h+t)w.scrollTo(e.offsetLeft,e.offsetTop-h+e.offsetHeight);};HTMLArea.prototype.getHTML=function(){switch(this._editMode){case"wysiwyg":if(!this.config.fullPage){return HTMLArea.getHTML(this._doc.body,false,this);}
+else{return this.doctype+"\n"+HTMLArea.getHTML(this._doc.documentElement,true,this);}
+case"textmode":return this._textArea.value;}
+return false;};HTMLArea.prototype.getInnerHTML=function(){switch(this._editMode){case"wysiwyg":if(!this.config.fullPage)return this._doc.body.innerHTML;else return this.doctype+"\n"+this._doc.documentElement.innerHTML;case"textmode":return this._textArea.value;}
+return false;};HTMLArea.prototype.setHTML=function(html){switch(this._editMode){case"wysiwyg":if(!this.config.fullPage)this._doc.body.innerHTML=html;else this._doc.body.innerHTML=html;break;case"textmode":this._textArea.value=html;break;}
+return false;};HTMLArea.prototype.setDoctype=function(doctype){this.doctype=doctype;};HTMLArea._object=null;HTMLArea.checkSupportedBrowser=function(){if(HTMLArea.is_gecko&&!HTMLArea.is_safari&&!HTMLArea.is_opera){if(navigator.productSub<20030210)return false;}
+return HTMLArea.is_gecko||HTMLArea.is_ie;};HTMLArea._eventCacheConstructor=function(){var listEvents=[];return({listEvents:listEvents,add:function(node,sEventName,fHandler){listEvents.push(arguments);},flush:function(){var item;for(var i=listEvents.length;--i>=0;){item=listEvents[i];try{HTMLArea._removeEvent(item[0],item[1],item[2]);item[0][item[1]]=null;item[0]=null;item[2]=null;}catch(e){}}}});};HTMLArea._addEvent=function(el,evname,func,useCapture){if(typeof(useCapture)=="undefined")var useCapture=false;if(HTMLArea.is_gecko){el.addEventListener(evname,func,!HTMLArea.is_opera||useCapture);}else{el.attachEvent("on"+evname,func);}
+HTMLArea._eventCache.add(el,evname,func);};HTMLArea._addEvents=function(el,evs,func,useCapture){if(typeof(useCapture)=="undefined")var useCapture=false;for(var i=evs.length;--i>=0;){HTMLArea._addEvent(el,evs[i],func,useCapture);}};HTMLArea._removeEvent=function(el,evname,func){if(HTMLArea.is_gecko){try{el.removeEventListener(evname,func,true);el.removeEventListener(evname,func,false);}catch(e){}}else{try{el.detachEvent("on"+evname,func);}catch(e){}}};HTMLArea._removeEvents=function(el,evs,func){for(var i=evs.length;--i>=0;){HTMLArea._removeEvent(el,evs[i],func);}};HTMLArea._stopEvent=function(ev){if(HTMLArea.is_gecko){ev.stopPropagation();ev.preventDefault();}else{ev.cancelBubble=true;ev.returnValue=false;}};HTMLArea._removeClass=function(el,removeClassName){if(!(el&&el.className))return;var cls=el.className.trim().split(" ");var ar=new Array();for(var i=cls.length;i>0;){if(cls[--i]!=removeClassName)ar[ar.length]=cls[i];}
+if(ar.length==0){if(!HTMLArea.is_opera)el.removeAttribute(HTMLArea.is_gecko?"class":"className");else el.className='';}else el.className=ar.join(" ");};HTMLArea._addClass=function(el,addClassName){HTMLArea._removeClass(el,addClassName);if(el.className)el.className+=" "+addClassName;else el.className=addClassName;};HTMLArea._hasClass=function(el,className){if(!el||!el.className)return false;var cls=el.className.split(" ");for(var i=cls.length;i>0;){if(cls[--i]==className)return true;}
+return false;};HTMLArea.RE_blockTags=/^(body|p|h1|h2|h3|h4|h5|h6|ul|ol|pre|dl|div|noscript|blockquote|form|hr|table|fieldset|address|td|tr|th|li|tbody|thead|tfoot|iframe|object)$/;HTMLArea.isBlockElement=function(el){return el&&el.nodeType==1&&HTMLArea.RE_blockTags.test(el.nodeName.toLowerCase());};HTMLArea.RE_closingTags=/^(p|span|a|li|ol|ul|dl|dt|td|th|tr|tbody|thead|tfoot|caption|table|div|em|i|strong|b|code|cite|blockquote|q|dfn|abbr|acronym|font|center|object|embed|tt|style|script|title|head|clickenlarge)$/;HTMLArea.RE_noClosingTag=/^(img|br|hr|input|area|base|link|meta|param)$/;HTMLArea.needsClosingTag=function(el){return el&&el.nodeType==1&&!HTMLArea.RE_noClosingTag.test(el.tagName.toLowerCase());};HTMLArea.htmlDecode=function(str){str=str.replace(/&lt;/g,"<").replace(/&gt;/g,">");str=str.replace(/&nbsp;/g,"\xA0");str=str.replace(/&quot;/g,"\x22");str=str.replace(/&#39;/g,"'");str=str.replace(/&amp;/g,"&");return str;};HTMLArea.htmlEncode=function(str){if(typeof(str)!='string')str=str.toString();str=HTMLArea.htmlDecode(str);str=str.replace(/&/g,"&amp;");str=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");str=str.replace(/\xA0/g,"&nbsp;");str=str.replace(/\x22/g,"&quot;");str=str.replace(HTMLArea.Reg_entities,"&$1;");return str;};HTMLArea.getHTML=function(root,outputRoot,editor){try{return HTMLArea.getHTMLWrapper(root,outputRoot,editor);}catch(e){HTMLArea._appendToLog("The HTML document is not well-formed.");if(!HTMLArea._debugMode)alert(HTMLArea.I18N.msg["HTML-document-not-well-formed"]);else return HTMLArea.getHTMLWrapper(root,outputRoot,editor);return editor._doc.body.innerHTML;}};HTMLArea.getHTMLWrapper=function(root,outputRoot,editor){var html="";if(!root)return html;switch(root.nodeType){case 1:case 11:case 9:var closed,i,config=editor.config;var root_tag=(root.nodeType==1)?root.tagName.toLowerCase():'';if(root_tag=='br'&&config.removeTrailingBR&&!root.nextSibling&&HTMLArea.isBlockElement(root.parentNode)&&(!root.previousSibling||root.previousSibling.nodeName.toLowerCase()!='br'))break;if(config.htmlRemoveTagsAndContents&&config.htmlRemoveTagsAndContents.test(root_tag))break;var custom_tag=(config.customTags&&config.customTags.test(root_tag));var empty_root=(root_tag=="clickenlarge"&&!(root.firstChild&&root.firstChild.nodeName.toLowerCase()=="img"));if(outputRoot)outputRoot=!(config.htmlRemoveTags&&config.htmlRemoveTags.test(root_tag))&&!empty_root;if((HTMLArea.is_ie||HTMLArea.is_safari)&&root_tag=="head"){if(outputRoot)html+="<head>";var save_multiline=RegExp.multiline;RegExp.multiline=true;var txt=root.innerHTML.replace(HTMLArea.RE_tagName,function(str,p1,p2){return p1+p2.toLowerCase();});RegExp.multiline=save_multiline;html+=txt;if(outputRoot)html+="</head>";break;}else if(outputRoot){if(HTMLArea.is_gecko&&root.hasAttribute('_moz_editor_bogus_node'))break;closed=(!(root.hasChildNodes()||HTMLArea.needsClosingTag(root)||custom_tag));html="<"+root_tag;var a,name,value,attrs=root.attributes;var n=attrs.length;for(i=attrs.length;--i>=0;){a=attrs.item(i);name=a.nodeName.toLowerCase();if((!a.specified&&name!='value')||/_moz|contenteditable|_msh/.test(name))continue;if(!HTMLArea.is_ie||name!="style"){if(typeof(root[a.nodeName])!="undefined"&&name!="href"&&name!="src"&&name!="style"&&!/^on/.test(name)){value=root[a.nodeName];}else{value=a.nodeValue;if(HTMLArea.is_ie&&(name=="href"||name=="src"))value=editor.stripBaseURL(value);}}else{value=root.style.cssText;}
+if(/(_moz|^$)/.test(value))continue;if(HTMLArea.is_ie&&root_tag=="li"&&name=="value"&&a.nodeValue==0)continue;html+=" "+name+'="'+HTMLArea.htmlEncode(value)+'"';}
+if(html!="")html+=closed?" />":">";}
+for(i=root.firstChild;i;i=i.nextSibling){if(/^li$/i.test(i.tagName)&&!/^[ou]l$/i.test(root.tagName))html+="<ul>"+HTMLArea.getHTMLWrapper(i,true,editor)+"</ul>";else html+=HTMLArea.getHTMLWrapper(i,true,editor);}
+if(outputRoot&&!closed)html+="</"+root_tag+">";break;case 3:html=/^(script|style)$/i.test(root.parentNode.tagName)?root.data:HTMLArea.htmlEncode(root.data);break;case 8:if(!editor.config.htmlRemoveComments)html="<!--"+root.data+"-->";break;case 4:html+='<![CDATA['+root.data+']]>';break;case 5:html+='&'+root.nodeValue+';';break;case 7:html+='<?'+root.target+' '+root.data+' ?>';break;default:break;}
+return html;};HTMLArea.getPrevNode=function(node){if(!node)return null;if(node.previousSibling)return node.previousSibling;if(node.parentNode)return node.parentNode;return null;};HTMLArea.getNextNode=function(node){if(!node)return null;if(node.nextSibling)return node.nextSibling;if(node.parentNode)return node.parentNode;return null;};HTMLArea.removeFromParent=function(el){if(!el.parentNode)return;var pN=el.parentNode;pN.removeChild(el);return el;};HTMLArea.prototype.stripBaseURL=function(string){var baseurl=this.config.baseURL;baseurl=baseurl.replace(/[^\/]+$/,'');var basere=new RegExp(baseurl);string=string.replace(basere,"");baseurl=baseurl.replace(/^(https?:\/\/[^\/]+)(.*)$/,'$1');basere=new RegExp(baseurl);return string.replace(basere,"");};String.prototype.trim=function(){return this.replace(/^\s+/,'').replace(/\s+$/,'');};HTMLArea._makeColor=function(v){if(typeof(v)!="number"){return v;}
+var r=v&0xFF;var g=(v>>8)&0xFF;var b=(v>>16)&0xFF;return"rgb("+r+","+g+","+b+")";};HTMLArea._colorToRgb=function(v){if(!v)
+return'';function hex(d){return(d<16)?("0"+d.toString(16)):d.toString(16);};if(typeof(v)=="number"){var r=v&0xFF;var g=(v>>8)&0xFF;var b=(v>>16)&0xFF;return"#"+hex(r)+hex(g)+hex(b);}
+if(v.substr(0,3)=="rgb"){var re=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/;if(v.match(re)){var r=parseInt(RegExp.$1);var g=parseInt(RegExp.$2);var b=parseInt(RegExp.$3);return"#"+hex(r)+hex(g)+hex(b);}
+return null;}
+if(v.substr(0,1)=="#"){return v;}
+return null;};HTMLArea._postback=function(url,data,handler,addParams,charset){if(typeof(charset)=="undefined")var charset="utf-8";var req=null;if(window.XMLHttpRequest)req=new XMLHttpRequest();else if(window.ActiveXObject){var success=false;for(var k=0;k<HTMLArea.MSXML_XMLHTTP_PROGIDS.length&&!success;k++){try{req=new ActiveXObject(HTMLArea.MSXML_XMLHTTP_PROGIDS[k]);success=true;}catch(e){}}}
+if(req){var content='';for(var i in data){content+=(content.length?'&':'')+i+'='+encodeURIComponent(data[i]);}
+content+=(content.length?'&':'')+'charset='+charset;if(typeof(addParams)!="undefined")content+=addParams;if(url.substring(0,1)=='/'){var postUrl=_typo3_host_url+url;}else{var postUrl=_typo3_host_url+_editor_url+url;}
+function callBack(){if(req.readyState==4){if(req.status==200){if(typeof(handler)=='function')handler(req.responseText,req);HTMLArea._appendToLog("[HTMLArea::_postback]: Server response: "+req.responseText);}else{HTMLArea._appendToLog("ERROR [HTMLArea::_postback]: Unable to post "+postUrl+" . Server reported "+req.statusText);}}}
+req.onreadystatechange=callBack;function sendRequest(){HTMLArea._appendToLog("[HTMLArea::_postback]: Request: "+content);req.send(content);}
+req.open('POST',postUrl,true);req.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');window.setTimeout(sendRequest,500);}};Dialog=function(url,action,init,width,height,opener,editor,scrollbars){Dialog._open(url,action,init,(width?width:100),(height?height:100),opener,editor,scrollbars);};Dialog._open=function(url,action,init,width,height,_opener,editor,scrollbars){if(typeof(Dialog._modal)=="object"&&typeof(Dialog._modal.close)=="function"){Dialog._modal.close();Dialog._modal=null;}
+var dlg=window.open(url,'hadialog',"toolbar=no,location=no,directories=no,menubar=no,width="+width+",height="+height+",scrollbars="+scrollbars+",resizable=yes,modal=yes,dependent=yes,top=100,left=100");var obj=new Object();obj.dialogWindow=dlg;Dialog._dialog=obj;Dialog._modal=dlg;Dialog._arguments=null;if(typeof(init)!="undefined"){Dialog._arguments=init;}
+function capwin(w){if(HTMLArea.is_gecko){w.addEventListener("focus",function(ev){Dialog._parentEvent(ev);},false);}
+else{HTMLArea._addEvent(w,"focus",function(ev){Dialog._parentEvent(ev);});}
+for(var i=0;i<w.frames.length;i++){capwin(w.frames[i]);}}
+capwin(window);function closeDialog(){if(Dialog._dialog&&Dialog._dialog.dialogWindow){Dialog._dialog.dialogWindow.close();Dialog._dialog=null;}
+if(dlg&&!dlg.closed){dlg.close();dlg=null;}
+return false;}
+Dialog._return=function(val){if(val&&action){action(val);}
+function relwin(w){HTMLArea._removeEvent(w,"focus",function(ev){Dialog._parentEvent(ev);});try{for(var i=0;i<w.frames.length;i++){relwin(w.frames[i]);}}catch(e){}}
+relwin(window);HTMLArea._removeEvent(window,"unload",closeDialog);Dialog._dialog=null;};HTMLArea._addEvent(dlg,"unload",function(){if(typeof(Dialog)!="undefined")Dialog._return(null);return false;});HTMLArea._addEvent(window,"unload",closeDialog);};Dialog._parentEvent=function(ev){if(Dialog._modal&&!Dialog._modal.closed){if(!ev)var ev=window.event;var target=(ev.target)?ev.target:ev.srcElement;Dialog._modal.focus();HTMLArea._stopEvent(ev);}
+return false;};HTMLArea.prototype._popupDialog=function(url,action,init,width,height,_opener,scrollbars){if(typeof(_opener)=="undefined"||!_opener)var _opener=(this._iframe.contentWindow?this._iframe.contentWindow:window);if(typeof(scrollbars)=="undefined")var scrollbars="no";Dialog(this.popupURL(url),action,init,width,height,_opener,this,scrollbars);};HTMLArea.getElementById=function(tag,id){var el,i,objs=document.getElementsByTagName(tag);for(i=objs.length;--i>=0&&(el=objs[i]);){if(el.id==id)return el;}
+return null;};HTMLArea.edHidePopup=function(){Dialog._modal.close();setTimeout("if (typeof(browserWin) != 'undefined' && typeof(browserWin.focus) == 'function') browserWin.focus();",200);};var setRTEsizeByJS=function(divId,height,width){if(HTMLArea.is_gecko)height=height-25;else height=height-60;if(height>0)document.getElementById(divId).style.height=height+"px";if(HTMLArea.is_gecko)width="99%";else width="97%";document.getElementById(divId).style.width=width;};var lorem_ipsum=function(element,text){if(element.tagName.toLowerCase()=="textarea"&&element.id&&element.id.substr(0,7)=="RTEarea"){var editor=RTEarea[element.id.substr(7,8)]["editor"];editor.insertHTML(text);editor.updateToolbar();}};HTMLArea.initTimer=[];HTMLArea.onGenerateHandler=function(editorNumber){return(function(){document.getElementById('pleasewait'+editorNumber).style.display='none';document.getElementById('editorWrap'+editorNumber).style.visibility='visible';editorNumber=null;});};HTMLArea.initEditor=function(editorNumber){if(HTMLArea.checkSupportedBrowser()){document.getElementById('pleasewait'+editorNumber).style.display='block';document.getElementById('editorWrap'+editorNumber).style.visibility='hidden';if(HTMLArea.initTimer[editorNumber])window.clearTimeout(HTMLArea.initTimer[editorNumber]);if(!HTMLArea.is_loaded){HTMLArea.initTimer[editorNumber]=window.setTimeout("HTMLArea.initEditor("+editorNumber+");",150);}else{var RTE=RTEarea[editorNumber];var config=new HTMLArea.Config();config.toolbar=RTE["toolbar"];RTE["editor"]=new HTMLArea(RTE["id"],config);var editor=RTE["editor"];editor._typo3EditerNumber=editorNumber;editor._editorNumber=editorNumber;config=editor.config;config.buttons=RTE["buttons"];config.hideTableOperationsInToolbar=RTE["hideTableOperationsInToolbar"]?RTE["hideTableOperationsInToolbar"]:false;config.disableLayoutFieldsetInTableOperations=RTE["disableLayoutFieldsetInTableOperations"]?RTE["disableLayoutFieldsetInTableOperations"]:false;config.disableAlignmentFieldsetInTableOperations=RTE["disableAlignmentFieldsetInTableOperations"]?RTE["disableAlignmentFieldsetInTableOperations"]:false;config.disableSpacingFieldsetInTableOperations=RTE["disableSpacingFieldsetInTableOperations"]?RTE["disableSpacingFieldsetInTableOperations"]:false;config.disableBordersFieldsetInTableOperations=RTE["disableBordersFieldsetInTableOperations"]?RTE["disableBordersFieldsetInTableOperations"]:false;config.disableColorFieldsetInTableOperations=RTE["disableColorFieldsetInTableOperations"]?RTE["disableColorFieldsetInTableOperations"]:false;config.disablePCexamples=RTE["disablePCexamples"]?RTE["disablePCexamples"]:false;for(var plugin in RTE["plugin"]){if(RTE["plugin"][plugin]){editor.registerPlugin(plugin);}}
+if(RTE["defaultPageStyle"])config.defaultPageStyle=RTE["defaultPageStyle"];if(RTE["pageStyle"])config.pageStyle=RTE["pageStyle"];if(RTE["fontname"])config.FontName=RTE["fontname"];if(RTE["fontsize"])config.FontSize=RTE["fontsize"];if(RTE["colors"])config.colors=RTE["colors"];if(RTE["disableColorPicker"])config.disableColorPicker=RTE["disableColorPicker"];if(RTE["paragraphs"])config.FormatBlock=RTE["paragraphs"];config.width="auto";config.height="auto";config.sizeIncludesToolbar=true;config.fullPage=false;config.useHTTPS=RTE["useHTTPS"]?RTE["useHTTPS"]:false;config.disableEnterParagraphs=RTE["disableEnterParagraphs"]?RTE["disableEnterParagraphs"]:false;config.removeTrailingBR=RTE["removeTrailingBR"]?RTE["removeTrailingBR"]:false;config.keepButtonGroupTogether=(RTE["keepButtonGroupTogether"]&&HTMLArea.is_gecko&&!HTMLArea.is_wamcom&&!HTMLArea.is_opera)?RTE["keepButtonGroupTogether"]:false;config.useCSS=RTE["useCSS"]?RTE["useCSS"]:false;config.enableMozillaExtension=RTE["enableMozillaExtension"]?RTE["enableMozillaExtension"]:false;config.statusBar=RTE["statusBar"]?RTE["statusBar"]:false;config.cleanWordOnPaste=RTE["enableWordClean"]?true:false;config.htmlRemoveTags=RTE["htmlRemoveTags"]?RTE["htmlRemoveTags"]:null;config.htmlRemoveTagsAndContents=RTE["htmlRemoveTagsAndContents"]?RTE["htmlRemoveTagsAndContents"]:null;config.htmlRemoveComments=RTE["htmlRemoveComments"]?true:false;editor.onGenerate=HTMLArea.onGenerateHandler(editorNumber);editor.generate();return false;}}else{document.getElementById('pleasewait'+editorNumber).style.display='none';document.getElementById('editorWrap'+editorNumber).style.visibility='visible';}};
\ No newline at end of file
index e95934d..f47c7a7 100644 (file)
@@ -881,14 +881,22 @@ HTMLArea.prototype.generate = function () {
  * Size the iframe according to user's prefs or initial textarea
  */
 HTMLArea.prototype.sizeIframe = function(diff) {
+       var i;
        var height = (this.config.height == "auto" ? (this._textArea.style.height) : this.config.height);
        var textareaHeight = height;
+
+       var inlineObject = RTEarea[this._editorNumber].tceformsInlineObject;
+       var parentElements = RTEarea[this._editorNumber].tceformsDynTabs.split(',');
+       if (inlineObject) parentElements.push(inlineObject);
+
+       var dimensions = this.accessParentElements(parentElements, 'this.getDimensions()');
+                       
        if(height.indexOf("%") == -1) {
                height = parseInt(height) - diff;               
                if (this.config.sizeIncludesToolbar) {
-                       this._initialToolbarOffsetHeight = this._toolbar.offsetHeight;
-                       height -= this._toolbar.offsetHeight;
-                       height -= this._statusBar.offsetHeight;
+                       this._initialToolbarOffsetHeight = dimensions.toolbar.height;
+                       height -= dimensions.toolbar.height;
+                       height -= dimensions.statusbar.height;
                }
                if (height < 0) height = 0;
                textareaHeight = (height - 4);
@@ -904,13 +912,66 @@ HTMLArea.prototype.sizeIframe = function(diff) {
                iframeWidth = parseInt(textareaWidth) + "px";
                textareaWidth = parseInt(textareaWidth) - diff;
                if (textareaWidth < 0) textareaWidth = 0;
-               textareaWidth += "px";
+               textareaWidth += 'px';
        }
        this._iframe.style.width = "100%";
        if (HTMLArea.is_opera) this._iframe.style.width = iframeWidth;
        this._textArea.style.width = textareaWidth;
 };
 
+/**
+ * Get the dimensions of the toolbar and statusbar.
+ *
+ * @return     object          An object with width/height pairs for statusbar and toolbar.
+ * @author     Oliver Hader <oh@inpublica.de>
+ */
+HTMLArea.prototype.getDimensions = function() {
+       return {
+               toolbar: {width: this._toolbar.offsetWidth, height: this._toolbar.offsetHeight},
+               statusbar: {width: this._statusBar.offsetWidth, height: this._statusBar.offsetHeight}
+       };
+};
+
+/**
+ * Access an inline relational element and make it "accesible".
+ * If a parent object has the style "display: none", offsetWidth & offsetHeight are '0'.
+ *
+ * @params     object          callbackFunc: A function to be called, when the embedded objects are "accessible".
+ * @return     object          An object returned by the callbackFunc.
+ * @author     Oliver Hader <oh@inpublica.de>
+ */
+HTMLArea.prototype.accessParentElements = function(parentElements, callbackFunc) {
+       var result = {};
+       
+       if (parentElements.length) {
+               var currentElement = parentElements.pop();
+               var elementStyle = document.getElementById(currentElement).style;
+               var actionRequired = elementStyle.display == 'none';
+               
+               if (actionRequired) {
+                       var originalVisibility = elementStyle.visibility;
+                       var originalPosition = elementStyle.position;
+                       elementStyle.visibility = 'hidden';
+                       elementStyle.position = 'absolute';
+                       elementStyle.display = '';
+               }
+               
+               result = this.accessParentElements(parentElements, callbackFunc);
+               
+               if (actionRequired) {
+                       elementStyle.display = 'none';
+                       elementStyle.position = originalPosition;
+                       elementStyle.visibility = originalVisibility;
+               }
+               
+       } else {
+               result = eval(callbackFunc);            
+
+       }
+       
+       return result;
+};
+
 /*
  * Initialize the iframe
  */
index d36d152..227306e 100755 (executable)
@@ -1683,7 +1683,7 @@ $str.=$this->docBodyTagBegin().
                        $options = array(array());
                        $divs = array();
                        $JSinit = array();
-                       $id = 'DTM-'.t3lib_div::shortMD5($identString);
+                       $id = $this->getDynTabMenuId($identString);
                        $noWrap = $noWrap ? ' nowrap="nowrap"' : '';
 
                                // Traverse menu items
@@ -1793,6 +1793,17 @@ $str.=$this->docBodyTagBegin().
                }
                return $content;
        }
+       
+       /**
+        * Creates the id for dynTabMenus.
+        *
+        * @param       string          $identString: Identification string. This should be unique for every instance of a dynamic menu!
+        * @return      string          The id with a short MD5 of $identString and prefixed "DTM-", like "DTM-2e8791854a"
+        */
+       function getDynTabMenuId($identString) {
+               $id = 'DTM-'.t3lib_div::shortMD5($identString);
+               return $id;
+       }
 
        /**
         * Returns dynamic tab menu header JS code.