Remark:
I had to change "onBeforeExpand" because it is in use already for some jquery scripts. When I take that for a different script, accordion and tabs doesn't work. I just took onAfterExpand for the menu switch script. Now all functions are well.