
sideMenuAccordionInit = function(container) {
		//console.debug('sideMenuAccordion.js: init accordion for elm = ' + container);
			
		if(dojo.isIE)
		{
			var nonEmptyMenuContents = $$(".accordion_toggle + .accordion_content");
			var nonEmptyMenuToggles = nonEmptyMenuContents.collect(function(s){ 
				return s.up();
			});
			
			
			
			var myAccordion = new Fx.Accordion(nonEmptyMenuToggles, nonEmptyMenuContents);
			myAccordion.showThisHideOpen(-1);
			
			
			var portalSelectedNode = $('portalSelectedNode'); 
			if(portalSelectedNode)
			{
				var selectedMenuContentIndex = nonEmptyMenuContents.indexOf(portalSelectedNode.up().up());
				//console.debug('sideMenuAccordion.js: accordionIE debug: ' + selectedToggleIndex);
				//console.debug('sideMenuAccordion.js: accordionIE debug: ' + selectedMenuContentIndex);
				//if(selectedMenuContentIndex != -1) myAccordion.display(selectedMenuContentIndex);
				//myAccordion.display(0);
				myAccordion.showThisHideOpen(selectedMenuContentIndex);
			}
			
			
		}
		else{
			new accordion(container, {
				// The speed of the accordion
				resizeSpeed : 5,
				// The classnames to look for
				classNames : {
					// The standard class for the title bar
					toggle : 'accordion_toggle',
					// The class used for the active state of the title bar
					toggleActive : 'accordion_toggle_active',
					// The class used to find the content
					content : 'accordion_content'
				},
				// If you don't want the accordion to stretch to fit 
				// its content, set a value here, handy for horixontal examples.
				defaultSize : {
					height : null,
					width : null
				},
				// The direction of the accordion
				direction : 'vertical',
				// Should the accordion activate on click or say on mouseover? (apple.com)
				onEvent : 'mouseover'
			});

			var togglehandles = $$('.accordion_toggle');
			//firstchild 
			if ($$('.accordion_toggle:first')[0]){
				$$('.accordion_toggle:first')[0].down().addClassName('firstchild');
				// this adds the class 'firstchild' to the a-element under the first span of the accordion.
			}
			//console.debug('sideMenuAccordion.js: ..closingAccordions');
			var accs = $$('.accordion_toggle');
			accs.each(function(acc){
				var isSelected = 'portalSelectedNode';
				var accParent = $(acc.parentNode);
				
				//console.debug('sideMenuAccordion.js: try to hide menu item: ' + accParent.id);

				// if selected branch, then don't hide
				if(accParent.id == isSelected
					|| accParent.select('#'+isSelected).size() != 0
					) {

					$(acc).addClassName('accordion_toggle_disabled');
					return;
				}
				
				$(acc).observe('mouseover', function() {
					$(acc).addClassName('hover');
				});
				
				$(acc).observe('mouseout', function() {
					$(acc).removeClassName('hover');
				});

				if (acc.next(0)) $(acc.next(0)).setStyle({display: 'none'});
			});
		}
}

