var currentPageQuoti = 0;
var quotiIsPlaying = false;
	
$(document).ready(function(){
	
	var quotiInterval = setInterval(function(){
			
			quotiIsPlaying = true;
			$(".q2_nav .fd").click();
			quotiIsPlaying = false;
			
		},4000);
		
	$(".tiret div").each(function(k,v){
		
		$(this).click(function(event){
			
			currentPageQuoti = k;
			
			loadBlocQuoti(event);
		});
	});

	$(".q2_nav .fg").click(function(event){
		
		if(currentPageQuoti>0){
			
			currentPageQuoti--;
		}else{
			
			currentPageQuoti = $(".tiret div").length-1;
		}
		
		loadBlocQuoti(event);
	});

	$(".q2_nav .fd").click(function(event){
		
		var tmp = -1;
		
		if( currentPageQuoti < ($(".tiret div").length-1) ){
			
			currentPageQuoti++;
			
		}else{
			
			currentPageQuoti = 0;
		}
		
		loadBlocQuoti(event);
	});
	
	$('.q2_nav').click(function(){
		
		
		clearInterval(quotiInterval);
	});

	function loadBlocQuoti(e){
		
		$(".tiret div").removeClass("on");
		$(".tiret div:eq("+currentPageQuoti+")").addClass("on");
		
		var prefixe = currentPageQuoti;
		
		
		if($(".tiret div:eq("+currentPageQuoti+")").attr('id')=="slideQjour"){
			
			prefixe = "qjour";
		}
		
		$.ajax({
			url:"/Quotidien/include/bloc_home_"+prefixe+".html",
			cache:false,
			success:function(r){
				
				$("#content-ajax").hide().html(r).fadeIn(600);
			}
		});
		
		
		/*
		$("#content-ajax").hide().load("/Quotidien/include/bloc_home_"+prefixe+".html",function(){
	
			$(this).fadeIn(600);
		});
		*/
		if(quotiIsPlaying){
			
			e.stopPropagation();
		}
	}
});