var menu_gauche= '';
var parentelement ='';

window.addEvent('domready', function(){
	menu_gauche = new Accordion('span.toggle', 'ul.menu_gauche_2', {
		display:false,
		alwaysHide:true,
		opacity: false,
	
		onBackground: function(toggler, element){
			toggler.setStyle('background-position', '0px -16px');
			
		},	
	
		onActive: function(toggler, element){
			toggler.setStyle('background-position', '0px 0px');	
			element.setStyle('visibility','visible');
			
		}
	});	

  function checkHash(){
    var found = false;
    var offset = 0;
    var tmp = 0;

    $$('#menu_gauche_1 li span.toggle').each(function(anchorid, i) {
     
	 /*
	 $$('#menu_gauche_1 li span.toggle').addEvent('mouseenter',function(){
			this.fireEvent('click');
		});
	*/	
		
	 if (anchorid.hasClass('open') && !found) {
          menu_gauche.display(offset);
          found = true;
      } else {
        offset++;
      }
    });

  /*if (!found) menu2.display(0);*/
  }

var x = new Chain();
x.chain(checkHash);  
x.callChain();
x.callChain.delay(1500, x);
/* Extension rgaccordion */
$$( '.rgaccord1-nest' ).each(function(item){
    var thisSlider = new Fx.Slide( item.getElement( '.rgaccord1-content' ), { duration: 500 } );
    thisSlider.hide();
  
    item.getElement( '.accordionToggler' ).addEvent( 'click', function(){ 
      thisSlider.toggle(); 

      // add the act class
      if (item.getElement( '.accordionToggler span' ).hasClass('act')) {
        item.getElement( '.accordionToggler span' ).removeClass('act');
      } else {
        item.getElement( '.accordionToggler span' ).addClass('act');
      }
    
    });
  });


/*Login Box*/
if ($('login_box') && $('toggle')) {
	var login_box = $('login_box');
	$('toggle').addEvent('click',function() {
		if (login_box.getStyle('display') == 'none') {
			login_box.setStyle ('display','block');
			
		} else {
			login_box.setStyle ('display','none');
		}
	});
	$('login_box_close').addEvent('click',function() {login_box.setStyle ('display','none');});
}
});


