window.addEvent('domready',function(e){
	var switchsatus = false;
	
	
	
	var clrzswitcher = new Element('div',{id:'clrz_switcher'});
	var spantitle = new Element('span',{'class':'titre'});
	
	 Elts = [];
	 inc = 0;
	 f = '';
	
	 new Element('a',{'class':'jdgnetwork','title':'alt + j'}).inject($$('div.header')[0],'bottom').set('text','JDG network').addEvent('mouseenter',openSwith);
	 
		$$('.footerlinks ul.top').getChildren('li').each(function(el,i){
			
			if(i<3)
			{
			
				var classe = el.getFirst().getProperty('href')[0].split('.')[1].toLowerCase();				
				Elts[i] = new Element('a').set('href',el.getFirst().getProperty('href')[0]);
				Elts[i].store('titre',el.getFirst().get('text')[0]).addClass(classe).inject(clrzswitcher,'bottom').addEvent('mouseenter',function(e){
					$clear(f);
					Elts.each(function(el,i){el.removeClass('current');});
					this.addClass('current');
					/*this.focus();*/
					spantitle.set('text',this.retrieve('titre'));
					
					});
			}
			
			});
			spantitle.inject(clrzswitcher,'bottom');
	clrzswitcherFX =  new Fx.Morph(clrzswitcher,{duration:600,transition: Fx.Transitions.Quint.easeOut,wait:false}).set({'opacity':0});
	clrzswitcher.inject(document.body,'bottom');
	clrzswitcher.addEvent('mouseenter',function(e){$clear(f);});
	
	
	function switchMe()
	{
		
		Elts[inc].fireEvent('mouseenter');	
		inc = inc+1;
		inc = (inc>(Elts.length-1)) ? 0 : inc;
		
	}
	
	function openSwith()
	{
		inc=0;
		switchMe();
		clrzswitcher.setStyles({'top':document.body.getScrollTop()+(document.body.getHeight()/2)});
		 clrzswitcherFX.start({'opacity':1});	
	}
	
	function showSwitch(delai)
	{
		delai = ($chk(delai)) ? delai : 1000;
		delai
		switchsatus = true;
		$clear(f);
		switchMe();
		clrzswitcher.setStyles({'top':document.body.getScrollTop()+(document.body.getHeight()/2)});
		 clrzswitcherFX.start({'opacity':1});
		/*f = (function(){ hideSwitch() }).delay(delai);*/
		
		window.addEvent( 'keyup', function( evt ){
		
   if( evt.code == 18)
   {
     hideSwitch();
 	 document.location.href=$$('#clrz_switcher a.current')[0].getProperty('href');
     }
    
     
	}); 
		
	}
	
	
	
	
	function hideSwitch()
	{
		switchsatus = false;
		 clrzswitcherFX.start({'opacity':0});
		
	}
	
	window.addEvent( 'keypress', function( evt ){
		
   if( evt.alt == true && evt.key == 'j' )
     showSwitch();
     
    
     
	}); 
	
	clrzswitcher.addEvent('mouseleave',function(e){
     
		hideSwitch();
		});
	
});