var psMenu = { init : function() { this.menu.init(); }, menu : { init : function() { var base = $( 'pe_pe_0' ); var baseWidth = base.getWidth()-6; $$( 'ul.level1' ).each( function( n ) { var nWidth = n.getWidth(); n.setStyle( {paddingLeft:(baseWidth-nWidth)+'px', visibility:'hidden'} ); } ); }, set : function( pe_id ) { if( pe_id == -1 ) return; $$('#pe_pe_0 li').each( function(n) { n.removeClassName( 'active' ); } ); $$('#pe_pe_0 ul.level1').each( function(n) { n.setStyle( {visibility:'hidden'} ); } ); hMenu = $('pe_ref_'+pe_id); if( !hMenu ) { alert( 'menu '+pe_id+' unknown!' ); return; } hMenu.select( 'a' )[0].blur(); if( hMenu.hasClassName( 'level0' ) ) { hMenu.addClassName( 'active' ); if( (hMenuSub=hMenu.select('#pe_pe_'+pe_id)[0]) ) { hMenuSub.setStyle( {visibility:'visible'} ); } } else if( hMenu.hasClassName( 'level1' ) ) { hParent = hMenu.up(); if( hParent.getStyle('visibility')!='visible' ) { hParent.setStyle( {visibility:'visible'} ); } hParent.up().addClassName( 'active' ); hParent.up().select( 'a' )[0].blur(); hMenu.addClassName( 'active' ); } } } }; document.observe( 'dom:loaded', function () { psMenu.init(); } );