$(document).ready(function()
{

	$("li.out a").attr("target","_blank");

	$(".magneto").click(function()
	{
		var actuel	= $(this).parent().children("div:visible").attr("class").split("_");
		var sens	=  $(this).attr("id");
		var lot		= actuel[1];
		
		if ( lot == 20 ) {
			if ( sens == "next") lot = 1;
			if ( sens == "prev") lot--; }
		else if ( lot == 1 ) {
			if ( sens == "next") lot++;
			if ( sens == "prev") lot = 20; }
		else if ( (lot > 1) && (lot < 20) ) {
			if ( sens == "next") lot++;
			if ( sens == "prev") lot--; }
		
		$("div.lot_" + actuel[1]).fadeOut(0, function(){ $("div.lot_" + lot).fadeIn(500); });
	});

	$(".magnetor").click(function()
	{
		var actuel	= $(this).parent().children("div:visible").attr("class").split("_");
		var sens	=  $(this).attr("id");
		var lot		= actuel[1];
		
		if ( lot == 5 ) {
			if ( sens == "nextr") lot = 1;
			if ( sens == "prevr") lot--; }
		else if ( lot == 1 ) {
			if ( sens == "nextr") lot++;
			if ( sens == "prevr") lot = 5; }
		else if ( (lot > 1) && (lot < 5) ) {
			if ( sens == "nextr") lot++;
			if ( sens == "prevr") lot--; }
		
		$("div.agd_" + actuel[1]).fadeOut(0, function(){ $("div.agd_" + lot).fadeIn(500); });
	});


	$(".dossier-sommaire").click(function()
	{
		var titre = $(this).html();
		$(".couverture").toggleClass("na");
		
		if ( titre == "Sommaire" )
		$(this).html("À la Une")
		else
		$(this).html("Sommaire")
	});
	
	/* Lien envoyer par mail */
	$("#tools .mail a").click(function(){
		
	});
	
	/* Gestion des encadrés */
	$("#bande .encart").each(function(){
		$(this).hide().append("<br/><a href='' class='close_encart'>(Fermer)</a>").prev().append(" <a href='' class='open_encart'>(Lire l'encadré)</a>");
	});
	$("#bande .open_encart").click(function(){
		$(this).parent().next(".encart").slideDown();
		return false;
	});
	$("#bande .close_encart").click(function(){
		$(this).parent().slideUp();
		return false;
	});
	
	/* Gestion des pubs flash IAB 120 x 240 */
	if ( $("#flash_iab_120_240").length > 0 )
	{
		$("#flash_iab_120_240").flash({
			swf:$("#flash_iab_120_240").attr('title'),
			width:119,
			height:240
		});
	}

}); // fin document.ready

