<?php
function makeMenu ($stab, $ssub, $help='') {
global $items;
global $sql;
$menu = '<div id="menu">';
$menu .= '<table border="0" cellspacing="0" cellpadding="0">';
$menu .= '<tr>';
$tabnr = 0;
foreach ($items as $tab) {
$url = '<a class="tlink" onfocus="blur()" href="'.$tab[1].'"> '.$tab[0].'  </a>';
if ($tabnr == 0) { // de eerste tab
$menu .= '<td background="images/balk_b.gif"><img src="images/balk_b.gif" width="50" height="32" border="0"></td>';
if ($tabnr == $stab) {
$menu .= '<td><img src="images/tabs_b.gif" width="22" height="32" border="0"></td>';
$menu .= '<td class="tab" background="images/tabs_c.gif">'.$url.'</td>';
$menu .= '<td><img src="images/tabs_mr.gif" width="22" height="32" border="0"></td>';
} else {
$menu .= '<td><img src="images/tab_b.gif" width="18" height="32" border="0"></td>';
$menu .= '<td class="tab" background="images/tab_c.gif">'.$url.'</td>';
if (($tabnr + 1) == $stab) { // de volgende tab is geselecteerd
$menu .= '<td><img src="images/tabs_ml.gif" width="22" height="32" border="0"></td>';
} else {
$menu .= '<td><img src="images/tab_m.gif" width="19" height="32" border="0"></td>';
}
}
} else if (count($items) == $tabnr + 1) { // de laatste tab
if ($tabnr == $stab) {
$menu .= '<td class="tab" background="images/tabs_c.gif">'.$url.'</td>';
$menu .= '<td><img src="images/tabs_e.gif" width="22" height="32" border="0"></td>';
} else {
$menu .= '<td class="tab" background="images/tab_c.gif">'.$url.'</td>';
$menu .= '<td><img src="images/tab_e.gif" width="18" height="32" border="0"></td>';
}
$menu .= '<td width="10000" background="images/balk_b.gif"></td>';
} else if ($tabnr == $stab) { // tab in het midden geselecteerd
$menu .= '<td class="tab" background="images/tabs_c.gif">'.$url.'</td>';
$menu .= '<td><img src="images/tabs_mr.gif" width="22" height="32" border="0"></td>';
} else { // tab in het midden
$menu .= '<td class="tab" background="images/tab_c.gif">'.$url.'</td>';
if (($tabnr + 1) == $stab) { // de volgende tab is geselecteerd
$menu .= '<td><img src="images/tabs_ml.gif" width="22" height="32" border="0"></td>';
} else {
$menu .= '<td><img src="images/tab_m.gif" width="19" height="32" border="0"></td>';
}
}
// het submenu genereren
if ($tabnr == $stab) {
$submenu = '<tr>';
$submenu .= '<td height="22" background="images/balk_o.gif"></td>';
$submenu .= '<td valign="top" colspan="'.(count($items) * 2 + 3).'" background="images/balk_o.gif">';
$subnr = 0;
$oldtitle='';
foreach ($tab[2] as $subitems) {
if ($subitems[2]<>'') {
$show=true;
foreach(split('\|',$subitems[2]) as $item) {
if ($_SESSION[$item]=='') {
$show=false;
}
}
if (! $show) {
continue;
}
}
$title='';
if ($subitems[3]<>'') {
$sql->Query($subitems[3]);
if ($sql->rows>0) {
$sql->fetch(0);
$title=$sql->data[title];
if (strlen($title)>20) {
$title=substr($title,0,20).'...';
}
} else {
continue;
}
}
$url = '<a class="slink" onfocus="blur()" href="'.$subitems[1].'"> '.$subitems[0].($title<>'' && $oldtitle<>$title?": $title":'').'  </a>';
if ($subnr == $ssub) {
$submenu .= '<span class="subs">'.$url.'</span>';
} else {
$submenu .= '<span class="sub">'.$url.'</span>';
}
$subnr++;
$oldtitle = $title;
}
$submenu .= '</td>';
$submenu .= '</tr>';
}
$tabnr++;
}
if ($help <> '') {
$menu .= '<td onClick="window.open(\''.$help.'\',\'Help\',\'width=500,height=500,location=no,top=200,left=500,menubar=no,scrollbars=yes,status=no,resizable=yes\'); no_bubble(event);"><img src="help.gif" alt="help"></td>';
}
$menu .= '</tr>'.$submenu;
$menu .= '</table>';
$menu .= '</div>';
print($menu);
}
?>