$(document).ready(function() {
	
	var oldIDX = 0;
	
	// --------- gestion du block ul1
	$(function() {
		$('.ul1 li').css('display', 'none');
		$('.ul1 li:eq(0)').css('display', 'block');
		$('.ul2 li').attr('class', 'no-selected');
		$('.ul2 li:eq(0)').attr('class', 'selected');
		$('.ul2 li:eq(3)').attr('class', 'no-selected last');
		
		//$("#block-mea4 div.actu-panel p").css({"display":"none"});
		$("#block-mea4 div.actu-panel").css({"height":"auto"});
		$("#block-mea4 ul.ul1 li img").hover(function() {
			$(this).css({'cursor':'pointer'});
		}, function () {
			$(this).css({'cursor':'pointer'});	
		});
		$("#block-mea4 ul.ul1 li img").click(function() {
			document.location = $(this).next().find('a').attr('href');
		});
		//$("#block-mea4 div.actu-panel").hover(function() {
		//	$(this).find('p').fadeIn('slow');
		//}, function() {
		//	$(this).find('p').fadeOut('slow');	
		//});
		
	});
	
	// --------- gestion du block ul2
	$(function() {
		
		
		$('.ul2 li .tnb img').css('cursor', 'pointer');		
		$('.ul2 li .tnb img').mouseover(function() {
			var idx = $('.ul2 li .tnb img').index(this);
			
			// on enleve la selection 
			if (oldIDX == 3) {
				$('.ul2 li:eq('+ oldIDX +')').attr('class', 'no-selected last');
			} else {
				$('.ul2 li:eq('+ oldIDX +')').attr('class', 'no-selected');
			}
			
			// on fade notre selection d'image
			$('.ul1 li:visible').fadeOut(250, function() {
				$('.ul1 li:eq('+ idx +')').fadeIn(250);
		      });
			
			// on set la selection
			if (idx == 3) {
				$('.ul2 li:eq('+ idx +')').attr('class', 'selected last');
			} else {
				$('.ul2 li:eq('+ idx +')').attr('class', 'selected');
			}
			
			// on garde la selection en memoire
			oldIDX = idx;
			
		});
	});	
	
	// --------- gestion du Scroll sur le bloc Other Actu	
	/*
	$(function() {
		$('.scroll-pane').jScrollPane();
	});
	*/
	
	// --------- gestion du slider des publication
	$(function() {
	    $("#pub-slider").jCarouselLite({
	    	circular: true,
	        btnNext: ".pub-next",
	        btnPrev: ".pub-prev"
	    });
	});

	

});

