/**
  * Return JS for preload dependent ctrl 
  *
  * @param string $fName - field name
  * @param string $fval - value of field
  * @return array
  */
 function getPreloadArr($fName, $value)
 {
     // category control field
     $strCategoryControl = $this->hasDependField($fName);
     if ($strCategoryControl === false) {
         return false;
     }
     // Is field appear or not
     $fieldAppear = true;
     if ($this->pageType == PAGE_ADD) {
         if (!AppearOnInlineAdd($fName)) {
             $fieldAppear = $this->mode != ADD_INLINE;
         } elseif (!AppearOnAddPage($fName)) {
             $fieldAppear = $this->mode == ADD_INLINE;
         }
         // Is category control appear or not
         if ($this->mode == ADD_INLINE) {
             if (AppearOnInlineAdd($strCategoryControl)) {
                 $categoryFieldAppear = true;
             } else {
                 $categoryFieldAppear = false;
             }
         } else {
             if (AppearOnAddPage($strCategoryControl)) {
                 $categoryFieldAppear = true;
             } else {
                 $categoryFieldAppear = false;
             }
         }
     } elseif ($this->pageType == PAGE_EDIT) {
         if (!AppearOnInlineEdit($fName)) {
             $fieldAppear = $this->mode != EDIT_INLINE;
         } elseif (!AppearOnEditPage($fName)) {
             $fieldAppear = $this->mode == EDIT_INLINE;
         }
         $categoryFieldAppear = true;
     } else {
         if ($strCategoryControl) {
             $categoryFieldAppear = true;
         } else {
             $categoryFieldAppear = false;
         }
     }
     if (!$fieldAppear) {
         return false;
     }
     if (GetFieldData($this->tName, $fName, 'freeInput', false)) {
         $output = array(0 => @$value[$fName], 1 => @$value[$fName]);
     } else {
         $output = loadSelectContent($fName, @$value[$strCategoryControl], $categoryFieldAppear, @$value[$fName]);
     }
     $valF = "";
     if (count($value)) {
         $valF = $value[$fName];
     }
     if ($this->pageType == PAGE_EDIT) {
         if (SelectSize($fName) == 1 && LookupControlType($fName) != LCT_CBLIST) {
             $fVal = $valF;
         } else {
             $fVal = splitvalues($valF);
         }
     } else {
         $fVal = $valF;
     }
     return array('vals' => $output, "fVal" => $fVal);
 }
/** Check is appear field on page by page type
 * param $fName - field name
 * param $pageType - type of current page
 *	return boolean/string - true or false/'break' - if need to break the cycle	
 */
function AppearOnCurrentPage($fName, $pageType, $pageLikeInline = false)
{
    if ($pageType == PAGE_LIST) {
        if (AppearOnListPage($fName)) {
            return true;
        } else {
            return AppearOnRegisterOrSearchPage($fName, PAGE_SEARCH);
        }
    } elseif ($pageType == PAGE_ADD) {
        if ($pageLikeInline) {
            if (AppearOnInlineAdd($fName) && AppearOnListPage($fName)) {
                return true;
            }
        } else {
            if (AppearOnAddPage($fName)) {
                return true;
            }
        }
    } elseif ($pageType == PAGE_EDIT) {
        if ($pageLikeInline) {
            if (AppearOnInlineEdit($fName) && AppearOnListPage($fName)) {
                return true;
            }
        } else {
            if (AppearOnEditPage($fName)) {
                return true;
            }
        }
    } elseif ($pageType == PAGE_SEARCH || $pageType == PAGE_REPORT || $pageType == PAGE_CHART) {
        return AppearOnRegisterOrSearchPage($fName, PAGE_SEARCH);
    } elseif ($pageType == PAGE_REGISTER) {
        return AppearOnRegisterOrSearchPage($fName, PAGE_REGISTER);
    } else {
        return 'break';
    }
    return false;
}