<?PHP
function type_form_img_treeview($formname, $content, $type_config, $dedi_side) {
		global $db, $dedi_db, $dedi_lang, $client, $perm, $cfg_dedi, $cfg_client, $__detree_header_printed;

		$content = type_form_dedilinks_to_templinks($content);
		//Standardfiletypes laden, wenn keine anderen angegeben, defaults laden
		$ft = strtolower(trim($type_config['filetypes']));
		$filetypes = ( empty($ft) || $ft == 'true' ) ? 'jpg,jpeg,gif,png': $ft;

		$filetypes_s = $type_config['filetypes'];
		$filetypes_s = str_replace(' ', '', $filetypes_s);
		$filetypes_s = ( empty($filetypes_s) || $filetypes_s == 'true' ) ? 'jpg,jpeg,gif,png': $filetypes_s;
		$filetypes = explode(',', $filetypes_s);

		$folders_s = $type_config['folders'];
		$folders = explode(',', $folders_s);

		$subfolders_s = $type_config['subfolders'];
		$subfolders = (trim($subfolders_s) == 'true');

		$subfolders = (trim(strtolower($subfolders_s)) != 'false');

		$sql = "SELECT iddirectory, parentid, name FROM ".$dedi_db['directory']." WHERE idclient=".$client." AND dirname NOT LIKE('cms/%') ORDER BY dirname";
		$db -> query($sql);

		$tree = array();
		while($db -> next_record()) {
			if($perm->have_perm(1, 'folder', $db->f('iddirectory'))) {
				$tree[$db->f('parentid')][] = $db->f('iddirectory');
				$folder[$db->f('iddirectory')] = str_replace("'", "\\'", $db->f('name'));
			};
		}

		$sql = "SELECT A.idupl idupl, A.filename filename, A.iddirectory iddirectory, A.titel titel, A.pictwidth width, A.pictheight height, B.filetype as filetype, C.dirname as directory FROM ".$dedi_db['upl']." AS A, ".$dedi_db['filetype']." AS B, ".$dedi_db['directory']." AS C WHERE A.idclient=".$client." AND C.idclient=".$client." AND A.idfiletype = B.idfiletype AND B.filetype IN ('".join($filetypes, "','")."') AND C.iddirectory = A.iddirectory ORDER BY filename";

		$db -> query($sql);
		$files = array();
		while($db -> next_record()) {
			if($perm->have_perm( 17, 'file', $db->f('idupl'), $db->f('iddirectory'))) {
				$thumb = preg_replace("/\.".$db->f('filetype')."$/i", $cfg_client['thumbext'].'.'.$db->f('filetype'), $db->f('directory').str_replace("'", "\\'", $db->f('filename')));
				if(!file_exists($cfg_client['upl_path'].$thumb)) $thumb = $db->f('directory').str_replace("'", "\\'", $db->f('filename'));
				$files[$db->f('iddirectory')][] = array(
					'ID'		=> $db->f('idupl'), 
					'NAME'		=> str_replace("'", "\\'", $db->f('filename')),
					'TITLE'		=> str_replace("'", "\\'", $db->f('titel')), 
					'TYPE'		=> $db->f('filetype'),
					'DIR'		=> $db->f('directory'), 
					'WIDTH'		=> $db->f('width'),
					'HEIGHT'	=> $db->f('height'), 
					'THUMB'		=> $thumb
				);
			}
		}
		$html_out = '		<td class="content type_form_img" width="640">';

		if(!$__detree_header_printed) {
			$__detree_header_printed = true;
			$html_out .= _type_print_dtree_header();
		}
		
		$html_out .= "
			<script type=\"text/javascript\">
dtree_$formname = new dTree('dtree_$formname');
dtree_$formname.config.useCookies = true;
dtree_$formname.config.inOrder = true;
dtree_$formname.config.folderLinks = false;
dtree_$formname.icon.root		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.root;
dtree_$formname.icon.folder		= '$cfg_dedi[dedi_html_path]external/bbcode/img/cfolder.gif';
dtree_$formname.icon.folderOpen		= '$cfg_dedi[dedi_html_path]external/bbcode/img/ofolder.gif';
dtree_$formname.icon.node		= '$cfg_dedi[dedi_html_path]external/bbcode/img/blank.gif';
dtree_$formname.icon.empty		= '$cfg_dedi[dedi_html_path]external/bbcode/img/empty.gif';
dtree_$formname.icon.line		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.line;
dtree_$formname.icon.join		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.join;
dtree_$formname.icon.joinBottom		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.joinBottom;
dtree_$formname.icon.plus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.plus;
dtree_$formname.icon.plusBottom		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.plusBottom;
dtree_$formname.icon.minus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.minus;
dtree_$formname.icon.minusBottom	= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.minusBottom;
dtree_$formname.icon.nlPlus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.nlPlus;
dtree_$formname.icon.nlMinus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.nlMinus;
dtree_$formname.add(0, -1, '$dedi_lang[bbcode_files]');
dtree_$formname.add(1, 0, '<span class=\"greyed\">$dedi_lang[bbcode_no_file_selected]</span>', 'javascript:form_img_set(\\'$formname\\', 0, \'\', 0, 0, \'\', \'\');');\n";

$selid = 1;
$preview = $cfg_client['space'];
$iid = 1;
$ok = false;
if(empty($folders_s) || $folders_s == 'true') {
  if(count($tree) >= 0)
    foreach($tree[0] as $a) {
	  $html_out .= _type_img_print_folder($a, 0, $formname, $folder, $tree, $files, $iid, $subfolders, $content, $sel);
	  $ok = true;
	}
} else { 
  if(count($folder) >= 0)
    foreach($folder as $n => $v) {
      if(in_array($n, $folders)) {
        $html_out .= _type_img_print_folder($n, 0, $formname, $folder, $tree, $files, $iid, $subfolders, $content, $sel);
        $ok = true;
      }
    }
}

if(!$ok) $html_out .= "dtree_$formname.add(1, 0, '<span class=\"greyed\">$dedi_lang[bbcode_insufficient_rights]</span>');\n";

$selid = ($sel['IID'] == 0) ? 1 : $sel['IID'];
$preview = $cfg_client['upl_htmlpath'].$sel['THUMB'];
$bigpreview = $sel['DIR'].$sel['NAME'];
$bigpreview_w = $sel['WIDTH'];
$bigpreview_h = $sel['HEIGHT'];
$bigpreview_t = (empty($sel['TITLE']) ? $sel['NAME'] : $sel['TITLE']);
$html_out .= 
"document.write(dtree_$formname);
dtree_$formname.openTo($selid, true);
dtree_jumps.push('sdtree_{$formname}{$selid}');

				</script>
				<a id=\"{$formname}preview_link\" title=\"$bigpreview_t,$bigpreview_w,$bigpreview_h\" href=\"{$cfg_client[upl_htmlpath]}{$bigpreview}\" onclick=\"return open_pic_popup(this.href, this.title);\"><img id=\"{$formname}preview\" class=\"preview\" src=\"$preview\" title=\"$bigpreview_t\" alt=\"$bigpreview_t\"/></a>
				<input type=\"hidden\" name=\"$formname\" id=\"$formname\" value=\"$content\">
			</td>\n";
        return $html_out;
}
function _type_img_print_folder($id, $ipid, $formname, &$folder, &$tree, &$files, &$iid, &$subfolders, &$content, &$sel) {
  global $cfg_dedi, $cfg_client;
  if(isset($folder[$id])) {
    $iid++;
    $html_out .= "dtree_$formname.add($iid, $ipid, '$folder[$id]');\n";
    $miid = $iid;
    if(is_array($files[$id])) {
      foreach($files[$id] as $a) {
        $iid++;
        if($a['ID'] == $content) { 
			$sel = $a;
			$sel['IID'] = $iid;
		}
        $html_out .= "dtree_$formname.add($iid, $miid, '<span title=\\'$a[TITLE]\\'>$a[NAME]</span>', 'javascript:form_img_set(\\'$formname\\', $a[ID], \\'$a[THUMB]\\', \\'$a[WIDTH]\\', \\'$a[HEIGHT]\\', \\'$a[DIR]$a[NAME]\\', \\'".(empty($a['TITLE']) ? $a['NAME'] : $a['TITLE'])."\\')');\n";
      }
    }
    if(is_array($tree[$id]) && $subfolders) {
      foreach($tree[$id] as $a) {
        $html_out .= _type_img_print_folder($a, $miid, $formname, $folder, $tree, $files, $iid, $subfolders, $content, $sel);
      }
    }
    return $html_out;
  }
}

function type_form_link_treeview($formname, $content, $type_config, $dedi_side) {
        global $db, $dedi_db, $dedi_lang, $mod_lang, $client, $lang, $catlist, $cfg_dedi, $__detree_header_printed;

        $content = type_form_dedilinks_to_templinks($content);

		$sql = "SELECT A.name, B.idcat, B.parent, B.sortindex FROM $dedi_db[cat_lang] AS A, $dedi_db[cat] AS B WHERE A.idcat=B.idcat AND B.idclient='$client' ORDER BY B.parent, B.sortindex";
		$db->query($sql);
		while ($db->next_record()){
				$cat[$db->f('idcat')] = str_replace("'", "\\'", $db->f('name'));
				$tlo_tree[$db->f('parent')][$db->f('sortindex')] = $db->f('idcat');
		}
		//tree_level_order_light();
		$sql = "SELECT D.idcatside, D.idcat, D.sortindex, D.is_start, F.title FROM $dedi_db[cat_side] AS D, $dedi_db[side] AS E, $dedi_db[side_lang] AS F WHERE D.idside=E.idside AND E.idside=F.idside AND E.idclient='$client' AND F.idlang='$lang' ORDER BY D.idcatside";
		$db->query($sql);
		while ($db->next_record()){
				$side[$db->f('idcat')][$db->f('idcatside')]['name'] = str_replace("'", "\\'", $db->f('title'));
				$side[$db->f('idcat')][$db->f('idcatside')]['idcatside'] = $db->f('idcatside');
				$side[$db->f('idcat')][$db->f('idcatside')]['is_start'] = $db->f('is_start');
				if($db->f('is_start') == 1){ $side['start'][$db->f('idcat')] = $db->f('idcatside'); }
				if(!is_array($side['sortarray'][$db->f('idcat')])){$side['sortarray'][$db->f('idcat')] = array(); }
				array_push($side['sortarray'][$db->f('idcat')],$db->f('sortindex'));
		}

		$tree = array();
		foreach($catlist as $a){
				$temp['id'] = $a;
				$temp['name'] = $cat[$a];
				$temp['level'] = $catlist_level[$a];
				if(isset($side['start'][$a])){ $temp['typ'] = "o"; } else { $temp['typ'] = "i"; }
				array_push($tree, $temp);
				if(is_array($side[$a])){
						array_multisort($side['sortarray'][$a] , SORT_ASC , $side[$a] , SORT_ASC);
						foreach(array_keys($side[$a]) as $b){
								$temp['id'] = $side[$a][$b]['idcatside'];
								$temp['name'] = str_replace("'", "\\'", $side[$a][$b]['name']);
								$temp['level'] = $catlist_level[$a] + 1;
								$temp['typ'] = "s";
								array_push($tree, $temp);
						}
				}
		}

		$exp = array();
		$sql = "SELECT idcat FROM $dedi_db[cat_expand] WHERE idusers = 1";
		$db->query($sql);
		while ($db->next_record()) { $exp[$db->f('idcat')] = true; }
		
		$html_out = '		<td class="content" width="640">';

		if(!$__detree_header_printed) {
			$__detree_header_printed = true;
			$html_out .= _type_print_dtree_header();
		}
		
		$html_out .= "
			<script type=\"text/javascript\">
dtree_$formname = new dTree('dtree_$formname');
dtree_$formname.config.useCookies = true;
dtree_$formname.config.inOrder = true;
dtree_$formname.config.folderLinks = false;
dtree_$formname.icon.root		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.root;
dtree_$formname.icon.folder		= '$cfg_dedi[dedi_html_path]external/bbcode/img/dedi_folder.gif';
dtree_$formname.icon.folderOpen	= '$cfg_dedi[dedi_html_path]external/bbcode/img/dedi_folder.gif';
dtree_$formname.icon.node		= '$cfg_dedi[dedi_html_path]external/bbcode/img/dedi_side.gif';
dtree_$formname.icon.empty		= '$cfg_dedi[dedi_html_path]external/bbcode/img/empty.gif';
dtree_$formname.icon.line		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.line;
dtree_$formname.icon.join		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.join;
dtree_$formname.icon.joinBottom	= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.joinBottom;
dtree_$formname.icon.plus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.plus;
dtree_$formname.icon.plusBottom	= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.plusBottom;
dtree_$formname.icon.minus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.minus;
dtree_$formname.icon.minusBottom	= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.minusBottom;
dtree_$formname.icon.nlPlus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.nlPlus;
dtree_$formname.icon.nlMinus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.nlMinus;
dtree_$formname.add(0, -1, '$dedi_lang[bbcode_pages]');
dtree_$formname.add(1, 0, '<span class=\"greyed\">$dedi_lang[bbcode_no_page_selected]</span>', 'javascript:form_link_set(\\'$formname\\', 0, true);');\n";

$II = 1;
$selid = 0;
/* print_r($tlo_tree);
print_r($cat);
print_r($side); */
foreach($tlo_tree[0] as $a) $html_out .= _type_link_print_cat($a, 0, $formname, $II, $cat, $side, $tlo_tree, $exp, $content, $selid);

//if(!$ok) $html_out .= "dtree_$formname.add(1, 0, '<span class=\"greyed\">Sie haben ungenügende Rechte</span>', null, null, null, '$cfg_dedi[dedi_html_path]external/bbcode/img/blank.gif', '$cfg_dedi[dedi_html_path]external/bbcode/img/blank.gif');\n";

$selid = ($selid == 0) ? 1 : $selid;
$html_out .= 
"document.write(dtree_$formname);
dtree_$formname.openTo($selid, true);
dtree_jumps.push('sdtree_{$formname}{$selid}');
				</script>
				<input type=\"hidden\" name=\"{$formname}\" id=\"$formname\" value=\"$content\">
				<label for=\"{$formname}extern\">$mod_lang[link_extern]:</label><input type=\"text\" name=\"{$formname}extern\" id=\"{$formname}extern\" value=\"" . (is_numeric($content) ? '' : $content) ."\" size=\"28\" style=\"width:100%\" onchange=\"form_link_set('$formname', this.value, false);\">
			</td>\n";
			return $html_out;
}

function _type_link_print_cat($ID, $PI, &$formname, &$II, &$cat, &$side, &$tlo_tree, &$exp, &$value, &$selid) {
  global $cfg_dedi;
  
  $html_out = "";
  $II++;
  $MI = $II;
  $html_out .= "dtree_$formname.add($II, $PI, '$cat[$ID]', null, null, null, null, null, " . (isset($exp[$ID]) ? 'true' : 'false') . ");\n";
  $html_out .= _type_link_print_side($ID, $MI, $formname, $II, $side, $value, $selid);
  if(is_array($tlo_tree[$ID])) {
    foreach($tlo_tree[$ID] as $a) {
      $html_out .= _type_link_print_cat($a, $MI, $formname, $II, $cat, $side, $tlo_tree, $exp, $value, $selid);
    }
  }
  return $html_out;
}

function _type_link_print_side($P, $PI, &$formname, &$II, &$side, &$value, &$selid) {
  global $cfg_dedi;
  
  $html_out = "";
  if(is_array($side[$P])) {
    foreach($side[$P] as $a) {
      $II++;
	  if($value == $a['idcatside']) $selid = $II;
      $first = $a['is_start'] ? 'first' : '';
      $html_out .= "dtree_$formname.add($II, $PI, '" . $a['name'] . "', 'javascript:form_link_set(\\'$formname\\', $a[idcatside], true);', null, null, " . ($a['is_start'] ? "'$cfg_dedi[dedi_html_path]external/bbcode/img/dedi_firstside.gif', '$cfg_dedi[dedi_html_path]external/bbcode/img/dedi_firstside.gif'" : "null, null") . ");\n";
    }
  }
  return $html_out;
}

function type_form_file_treeview($formname, $content, $type_config, $dedi_side) {
		global $db, $perm, $dedi_db, $dedi_lang, $client, $deditag_config, $cfg_dedi, $__detree_header_printed;

		$content = type_form_dedilinks_to_templinks($content);

		$filetypes_s = strtolower($type_config['filetypes']);
		$folders_s = $type_config['folders'];
		$subfolders_s = $type_config['subfolders'];
        
		$folders_s = str_replace(' ', '', $folders_s);
		$folders = explode(',', $folders_s);

		$filetypes_s = str_replace(' ', '', $filetypes_s);
		$filetypes = explode(',', $filetypes_s);
		
		$subfolders = (trim(strtolower($subfolders_s)) != 'false');
		
		$sql = "SELECT iddirectory, parentid, name FROM ".$dedi_db['directory']." WHERE idclient=".$client." AND dirname NOT LIKE('cms/%') ORDER BY dirname";
		$db -> query($sql);

		$tree = array();
		while($db -> next_record()) {
			if($perm->have_perm(1, 'folder', $db->f('iddirectory'))) {
				$tree[$db->f('parentid')][] = $db->f('iddirectory');
				$folder[$db->f('iddirectory')] = str_replace("'", "\\'", $db->f('name'));
			};
		}


		if((!empty($filetypes_s) && $filetypes_s != 'true'))
		$sql = "SELECT A.idupl idupl, A.filename filename, A.iddirectory iddirectory, A.titel titel FROM ".$dedi_db['upl']." AS A, ".$dedi_db['filetype']." AS B WHERE idclient=".$client." AND A.idfiletype = B.idfiletype AND B.filetype IN ('".join($filetypes, "','")."') ORDER BY filename";
		else
		$sql = "SELECT idupl, filename, iddirectory, titel FROM ".$dedi_db['upl']." WHERE idclient=".$client." ORDER BY filename";;

		$db -> query($sql);
		$files = array();
		while($db -> next_record()) {
			if($perm->have_perm( 17, 'file', $db->f('idupl'), $db->f('iddirectory'))) {
				$files[$db->f('iddirectory')][] = array(
					'ID'		=> $db->f('idupl'), 
					'NAME'		=> str_replace("'", "\\'", $db->f('filename')),
					'TITLE'		=> str_replace("'", "\\'", $db->f('titel'))
				);
			}
		}
		$html_out = '		<td class="content" width="640">';

		if(!$__detree_header_printed) {
			$__detree_header_printed = true;
			$html_out .= _type_print_dtree_header();
		}
		
		$html_out .= 
"			<script type=\"text/javascript\">
dtree_$formname = new dTree('dtree_$formname');
dtree_$formname.config.useCookies = true;
dtree_$formname.config.inOrder = true;
dtree_$formname.config.folderLinks = false;
dtree_$formname.icon.root		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.root;
dtree_$formname.icon.folder		= '$cfg_dedi[dedi_html_path]external/bbcode/img/cfolder.gif';
dtree_$formname.icon.folderOpen		= '$cfg_dedi[dedi_html_path]external/bbcode/img/ofolder.gif';
dtree_$formname.icon.node		= '$cfg_dedi[dedi_html_path]external/bbcode/img/blank.gif';
dtree_$formname.icon.empty		= '$cfg_dedi[dedi_html_path]external/bbcode/img/empty.gif';
dtree_$formname.icon.line		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.line;
dtree_$formname.icon.join		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.join;
dtree_$formname.icon.joinBottom		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.joinBottom;
dtree_$formname.icon.plus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.plus;
dtree_$formname.icon.plusBottom		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.plusBottom;
dtree_$formname.icon.minus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.minus;
dtree_$formname.icon.minusBottom	= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.minusBottom;
dtree_$formname.icon.nlPlus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.nlPlus;
dtree_$formname.icon.nlMinus		= '$cfg_dedi[dedi_html_path]external/bbcode/' + dtree_$formname.icon.nlMinus;
dtree_$formname.add(0, -1, '$dedi_lang[bbcode_files]');
dtree_$formname.add(1, 0, '<span class=\"greyed\">$dedi_lang[bbcode_no_file_selected]</span>', 'javascript:form_file_set(\\'$formname\\', 0)');\n";

$selid = 1;
$iid = 1;
$ok = false;
if(empty($folders_s) || $folders_s == 'true') {
  if(count($tree) >= 0)
    foreach($tree[0] as $a) {
	  $html_out .= _type_file_print_folder($a, 0, $formname, $folder, $tree, $files, $iid, $subfolders, $content, $selid);
	  $ok = true;
	}
} else { 
  if(count($folder) >= 0)
    foreach($folder as $n => $v) {
      if(in_array($n, $folders)) {
        $html_out .= _type_file_print_folder($n, 0, $formname, $folder, $tree, $files, $iid, $subfolders, $content, $selid);
        $ok = true;
      }
    }
}

if(!$ok) $html_out .= "dtree_$formname.add(1, 0, '<span class=\"greyed\">$dedi_lang[bbcode_insufficient_rights]</span>');\n";

$selid = ($selid == 0) ? 1 : $selid;
$html_out .= 
"document.write(dtree_$formname);
dtree_$formname.openTo($selid, true);
dtree_jumps.push('sdtree_{$formname}{$selid}');
				</script>
				<input type=\"hidden\" name=\"$formname\" id=\"$formname\" value=\"$content\">
			</td>\n";

        //Hidetarget auslesen und variable ins filetarget rüberretten, da die Werte der dedi:tags nur im Haupttag sichtbar sind
        global $filetarget_is_hidden;
        $filetarget_is_hidden = $type_config['hidetarget'];
        return $html_out;
}

function _type_file_print_folder($id, $ipid, $formname, &$folder, &$tree, &$files, &$iid, &$subfolders, &$content, &$selid) {
  global $cfg_dedi;
  if(isset($folder[$id])) {
    $iid++;
    $html_out .= "dtree_$formname.add($iid, $ipid, '$folder[$id]');\n";
    $miid = $iid;
    if(is_array($files[$id])) {
      foreach($files[$id] as $a) {
        $iid++;
        if($a['ID'] == $content) $selid = $iid;
        $html_out .= "dtree_$formname.add($iid, $miid, '<span title=\\'$a[TITLE]\\'>$a[NAME]</span>', 'javascript:form_file_set(\\'$formname\\', $a[ID])');\n";

      }
    }
    if(is_array($tree[$id]) && $subfolders) {
      foreach($tree[$id] as $a) {
        $html_out .= _type_file_print_folder($a, $miid, $formname, $folder, $tree, $files, $iid, $subfolders, $content, $selid);
      }
    }
    return $html_out;
  }
}

function _type_print_dtree_header() {
	global $cfg_dedi, $cfg_client;
	return '
			<style type="text/css">
.dtree{
 background:#FFFFFF;
 border:1px #DBE3EF inset;
 overflow:auto;
 height:200px;
}
.dtree .greyed{
 color:#666666;
}

.type_form_img .dtree{
 width:' . (640 - $cfg_client['thumb_size'] - 5) . 'px;
 float: left;
}
.type_form_img .preview{
 width:' . $cfg_client['thumb_size'] . 'px;
 /*display:block;*/
 border: none;
}

/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landrö               |
|--------------------------------------------------*/
.dtree{
 color:#666666;
 font:11px Verdana,Geneva,Arial,Helvetica,sans-serif;
 white-space:nowrap;
}
.dtree img{
 border:0px;
 vertical-align:middle;
}
.dtree a{
 color:#333333;
 text-decoration:none;
}
.dtree a.node,.dtree a.nodeSel{
 padding:1px 2px 1px 2px;
 white-space:nowrap;
}
.dtree a.node:hover,.dtree a.nodeSel:hover{
 color:#333333;
 text-decoration:underline;
}
.dtree a.nodeSel{
 background:#C0D2EC;
}
.dtree .clip{
 overflow:hidden;
}
/*-------------------\\ End dTree //---------------*/
			</style>
			<script type="text/javascript" src="' . $cfg_dedi['dedi_html_path'] . 'external/bbcode/dtree.js"></script>
			<script type="text/javascript">
function form_file_set(formname, value)
{
	var e = document.getElementById(formname);
	if(e) e.value = value;
}
function form_img_set(formname, value, preview, w, h, img, title)
{
	var e = document.getElementById(formname);
	if(e) e.value = value;
	
	var e = document.getElementById(formname + \'preview\');
	if(e) {
		e.title = title;
		e.alt = title;
		e.src = \'' . $cfg_client['upl_htmlpath'] . '\' + preview;
	}
	
	var e = document.getElementById(formname + \'preview_link\');
	if(e) {
		e.href = \'' . $cfg_client['upl_htmlpath'] . '\' + img;
		e.title = title + \',\' + w + \',\' + h;
	}
}
function form_link_set(formname, value, isintern)
{
	if(isintern) {
		var e = document.getElementById(formname);
		if(e) e.value = value;
		
		e = document.getElementById(formname + \'extern\');
		if(e) e.value = \'\';
	} else {
		var e = document.getElementById(formname);
		if(e) e.value = value;
		
		e = eval(formname);
		if(e) e.openTo(1, true);
	}
}

var pic_popup = null
function open_pic_popup(url, data)
{
	var tpop_bildschirmx = screen.availWidth;
	var tpop_bildschirmy = screen.availHeight;
	var opos = 0;
	var pos = data.indexOf(\',\');
	var windowtitle = (pos != -1 ? data.substring(0, pos) : \'\');
	opos = pos + 1;
	pos = data.indexOf(\',\', opos);
	var b = (pos != -1 ? data.substring(opos, pos) : \'\');
	opos = pos + 1;
	var h = (pos != -1 ? data.substring(opos) : \'\');
		
	var tpop_breite = b;
	var tpop_hoehe = h;

	var tpop_startx = Math.round(tpop_bildschirmx / 2) - (tpop_breite / 2);
	var tpop_starty = Math.round(tpop_bildschirmy / 2) - (tpop_hoehe / 2);

    if (pic_popup && !pic_popup.closed && pic_popup.close) pic_popup.close()
        
	pic_popup = window.open(\'about:blank\', \'popup\', "width="+ b + ", height=" + h
					+ ", status=no, toolbar=no, menubar=no, resizable=yes, scrollbars=no, screenX=" + tpop_startx
					+ ", left=" + tpop_startx + ", screenY=" + tpop_starty + ", top=" + tpop_starty + " ");
					
	pic_popup.focus();
	pic_popup.document.writeln(\'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\');
	pic_popup.document.writeln(\'<html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">\');
	pic_popup.document.writeln(\'<head><title>\' + windowtitle + \'</title>\');
	pic_popup.document.writeln(\'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\');
	pic_popup.document.writeln(\'<meta http-equiv="ImageToolbar" content="no" />\');
	pic_popup.document.writeln(\'<meta http-equiv="Language" content="de" />\');
	pic_popup.document.writeln(\'<style type="text/css"><!--\')
	pic_popup.document.writeln(\'body,div{margin:0;padding:0;overflow:hidden;}img{border:0 none;margin:0;padding:0;display:block;}\')
	pic_popup.document.writeln(\'--></style></head>\')
	pic_popup.document.writeln(\'<body><div>\')
	pic_popup.document.writeln(\'<a href="#" onclick="self.close()"><img src="\'+ url +\'" alt="\'+ windowtitle + \'" /></a>\')
	pic_popup.document.writeln(\'</div></body></html>\');
	pic_popup.document.close();

	return false;
}

var browser = navigator.userAgent.toLowerCase();
is_opera = (browser.indexOf("opera") != -1)

function dtree_jump() {
	//if(!is_opera) {
		for(var i = 0; i < dtree_jumps.length; i++) window.location.hash = dtree_jumps[i];
		window.scrollTo(0,0);
	//}
}
window.onload = dtree_jump;
var dtree_jumps = new Array();
			</script>
			<a name="top"> </a>
';
}
?>