// JavaScript Document
window.addEvent('domready', function() {
									 
	// HAUTEUR LISTE INITIAL
	var sizey_init = $('liste_actualites').getSize().y;
	
	// INIT EFFET OPACITE LISTE/FICHE
	var myEffect_list = new Fx.Morph($('liste_actualites'), {duration: 800, transition: Fx.Transitions.Pow.easeOut}).set({'opacity':1,'visibility':'visible'});
	var myEffect_fiche = new Fx.Morph($('xhr_actualites'), {duration: 800, transition: Fx.Transitions.Pow.easeOut}).set({'opacity':0,'visibility':'visible'});
	
	
	
	$$('ul.nav_actualites li').addEvent('click',function() {
												
		// INIT EFFET
		var myEffect = new Fx.Morph($('content_actualites').parentNode, {duration: 800, transition: Fx.Transitions.Pow.easeOut});
		
		
		// RECUPERER ID
		var get_id = this.get('id');
		longueur_str = get_id.length
		search_str = get_id.lastIndexOf('_');
		pos_str = search_str+1;
		var id = get_id.substring(pos_str,longueur_str)
		var data = 'fiche=actualite&id='+escape(id);
				
		// AJAX
		var xhr = getXMLHttpRequest();
		var URL = "http://www.ultranoir.com/html/gene/ajax/gen_fiche_actu.php";
		xhr.open("POST",URL,true);
		xhr.onreadystatechange = function() {
			if (xhr.readyState == 4){
				
				// AFFICHAGE DONNEES
				myEffect_list.start({'opacity':0,'display':'none'});
				myEffect_fiche.start({'opacity':1});
				//$('liste_actualites').set('style','display:none');
				$('xhr_actualites').set('html',xhr.responseText);
				var sizey = $('fiche_actualite').getSize().y;
				myEffect.start({ 'height': [sizey_init, sizey] });
				Shadowbox.init({ skipSetup: true }); Shadowbox.clearCache(); Shadowbox.setup();  
				
				// RETOUR LISTE
				$$('a.retour_actu').addEvent('click',function(e) {
					e.stop();
					$('xhr_actualites').empty();
					$('liste_actualites').set('style','display:block');	
					myEffect_fiche.start({'opacity':0});
					myEffect.start({ 'height': [sizey,sizey_init] });
				});
				
			}
		}
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send(data);

	});
	
	
	
	
});