var cat_en_cours = 0;

function sous_pages(cat){
	if(document.getElementById(cat).style.display=='none'){
		$("#"+cat).slideDown(400);
		if(cat_en_cours!=0 && cat_en_cours!=cat){
			$("#"+cat_en_cours).slideUp(400);
		}
		cat_en_cours=cat;
	}else{
		$("#"+cat).slideUp(400);
	}
}

function charge_page(cat){
	if(document.getElementById(cat).style.display=='none'){
		document.getElementById(cat).style.display='';
		cat_en_cours=cat;
	}	
}


var lecture = true;
var current_news=0;
var effet_en_cours = false;

function suivant_auto(){
	if(lecture == true){
		effet_en_cours = true;
		$("#actu_txt_" + current_news).fadeOut("slow",function(){
			document.getElementById('picto_nb_'+current_news).className = 'page lienpages';
			if(current_news == 2)
				current_news=0;
			else
				current_news++;
			$("#actu_txt_" + current_news).fadeIn("slow");
			effet_en_cours = false;
			document.getElementById('picto_nb_'+current_news).className = 'page lienpages_active';
			setTimeout("suivant_auto()", 5000);
		});
	}
}

function pause(){
	lecture = false;
}

function go_to_news(num){
	if(effet_en_cours == false){
		pause();
		effet_en_cours = true;
		
		document.getElementById('picto_nb_'+current_news).className = 'page lienpages';
		document.getElementById('picto_nb_'+num).className = 'page lienpages_active';
		$("#actu_txt_" + current_news).fadeOut("slow",function(){
			current_news=num;
			$("#actu_txt_" + current_news).fadeIn("slow");
			effet_en_cours = false;
		});
	}
}

setTimeout("suivant_auto()", 6000);


var photo_en_cours=0;

function photo_prec(){
	if(photo_en_cours>0){
		photo_en_cours--;
		new_margin_left=parseInt(photo_en_cours*419);
		$('#photos_accueil').animate({marginLeft: -new_margin_left+'px'}, 500);
	}
}
function photo_suiv(photo_max){
	if(photo_en_cours<photo_max-1){
		photo_en_cours++;
		new_margin_left=parseInt(photo_en_cours*419);
		$('#photos_accueil').animate({marginLeft: -new_margin_left+'px'}, 500);
	}
}


var id_en_cours="";
var anim=false;
var survol="";

$('body').click(function(){	
	//alert('plop');
	if(survol!=id_en_cours){
	$('ul.#propo_'+id_en_cours).slideUp(100,function(){
		id_en_cours="";
	});	
	}
});
			
function enroule_deroule(id) {	

	if(id_en_cours!=id){
		anim=true;
		$('ul.#propo_'+id).slideDown(150,function(){
			anim=false;
			id_en_cours=id;
		});	
	}else if(id_en_cours==id){
		anim=true;
		$('ul.#propo_'+id).slideUp(150,function(){
			anim=false;
			id_en_cours="";
		});	
	}
	
}

