@feherke
I was thinking about both, not just the things I posted.
Saw the general coding-style, so I guess there is a lot of optimization to be done, which also could make it more dynamic.
eg. I dont see him echo out any <li> or </li>, </ul>, also this:
if($level_depth1 ==0 or $level_depth1...