
// Carry out accordian styled effect
function accordion(evt) {
	
	el = Event.element(evt);
	
	var eldown = getNextSibling(el);
	
	//  If element is visible do nothing
	if ($('visible') == el) {
			return;
	}else{
		
		var elup = getNextSibling($('visible'));
		var eldown = getNextSibling(el);

		
		singleSlideHide(elup);
		singleSlideShow(eldown);

		$('visible').id = "";
		el.id = 'visible';
		
	}
}

// Setup accordian initial state

function init() {

	var menuTabElements = document.getElementsByClassName('menuBarTab');

	for (i = 0; i < menuTabElements.length; i++) {
		Event.observe(menuTabElements[i], 'click', accordion, false);
		if(menuTabElements[i].id != 'visible'){
			var elup = getNextSibling(menuTabElements[i]);
			singleSlideHide(elup);
			
		}
    }

}

// Next sibling method to work around firefox issues
function getNextSibling(startBrother){
	
	var endBrother=startBrother.nextSibling;
	//alert(endBrother);
  while(endBrother.nodeType !=1){
	
    endBrother = endBrother.nextSibling;
  }
  return endBrother;
}


function singleSlideHide( elup ){
	
		new Effect.Parallel(
		[
				new Effect.SlideUp(elup)
		], {
				duration: 0.2,
				
		});
}



function singleSlideShow( eldown ){
	
		new Effect.Parallel(
		[
				new Effect.SlideDown(eldown)
		], {
				duration: 0.2,
				
		});
}


function parellelSlide( elup, eldown ){
		new Effect.Parallel(
		[
				new Effect.SlideUp(elup),
				new Effect.SlideDown(eldown)
		], {
				duration: 0.3,
				
		});
}


Event.observe(window, 'load', init, false);
