function oxaslide(Slidew,Slideh,speed,speed2,move_type,auto,autodelay,alphaslide, speedduring){

/*(Slidew,Slideh,speed,speed2,move_type,auto,autodelay,alphaslide,speedduring)*/
/*(largeur de l'animation en px, hauteur de l'animation en px, vitesse du premier element en ms, vitesse du second element en ms, Type de transition de 0 à 4, Auto True or False, Delay Auto en ms, Alpha 0 ou 1 indique si l'animation joue sur l'alpha ou non )*/

var alt = 0 ;
var id = 0 ;
var current = 1 ;
var time_cpt = 1 ;
var flag = true ;
var flagaction = false ;
var flagfirst = false;




$('#cont-section-global').wrapInner('<div id="cont-overflow"><div id="cont-section"></div></div>');

//Pour chaque image...
$('#cont-section-global img').each(function(){
	$(this).parent().wrap('<div class="section" id="slide' + id + '"></div>');
	$(this).parent().after('<div class="inner-bg" style="background-image:url(' + $(this).attr('title') + ')" ></div>')
	$(this).parent().wrap('<div class="inner-img"></div>');
	$(this).removeAttr('title');
	id++;
	})

//Mise en place de la pagination
$('#cont-section-global').append('<div id="pagination"><ul></ul></div>');
$("#cont-section .inner-img img").each(function(){
	$("#pagination ul").append('<li><a alt="'+alt+'" class="btn-slide" id="btn-parallax-'+alt+'"></a></li>'); 
	alt++;
	})
	

//Action quand on clique sur une galerie
$("a.btn-slide").click(function (){
	if( (!$(this).hasClass('selected')) && flagaction ){
		flag=false;
		time_cpt=1;
		$("a.btn-slide").removeClass("selected");
		$(this).addClass("selected");	
		currentint=$(this).attr('alt');
		current = currentint++;
		open_slide($(this).attr('alt'));	
		}
	}
)

//Animation du header-menu
$("a.btn-slide").mouseover(function (){$(this).animate({ opacity : 0.7}, speed);})
$("a.btn-slide").mouseout(function (){$(this).animate({opacity  : 1}, speed);})
	
function open_slide(myslide){

		switch(move_type){
		
		case 0 :
			flagaction = false;
			$(".inner-bg").animate({opacity:alphaslide, top : -Slideh}, speed);
			$(".inner-img").animate({opacity:alphaslide, top : Slideh}, speed);

			$("#cont-section").delay(speedduring).animate({ top :  0}, 'slow',
				function (){		
					$("#slide" + myslide + " .inner-bg").animate({opacity:1, top : 0}, speed );
					$("#slide" + myslide + " .inner-img").animate({opacity:1, top : 0}, speed2, function(){ flagaction = true; } );
					}	
				);		
		break;
		
		case 1 :
			flagaction = false;
			$(".inner-bg").animate({opacity:alphaslide, left : -Slidew}, speed);
			$(".inner-img").animate({opacity:alphaslide, left : Slidew}, speed);	
			
			$("#cont-section").delay(speedduring).animate({ top :  0}, 'slow',			
				function (){		
					$("#slide" + myslide + " .inner-bg").animate({opacity:1, left : 0}, speed );
					$("#slide" + myslide + " .inner-img").animate({opacity:1, left : 0}, speed2, function(){ flagaction = true; } );
					}	
				);		
		break;
		
		
		case 2 :
			flagaction = false;
			$(".inner-bg").animate({opacity:alphaslide, top : -Slideh}, speed);
			$(".inner-img").animate({opacity:alphaslide, left : Slidew}, speed);

			$("#cont-section").delay(speedduring).animate({ top :  0}, 'slow',
				function (){		
					$("#slide" + myslide + " .inner-bg").animate({opacity:1, top : 0}, speed );
					$("#slide" + myslide + " .inner-img").animate({opacity:1, left : 0}, speed2, function(){ flagaction = true; } );
					}	
				);		
		break;
		
		case 3 :
			flagaction = false;
			$(".inner-bg").animate({opacity:alphaslide, top : Slideh}, speed);
			$(".inner-img").animate({opacity:alphaslide, left : -Slidew}, speed);	
			
			$("#cont-section").delay(speedduring).animate({ top :  0}, 'slow',			
				function (){		
					$("#slide" + myslide + " .inner-bg").animate({opacity:1, top : 0}, speed );
					$("#slide" + myslide + " .inner-img").animate({opacity:1, left : 0}, speed2, function(){ flagaction = true; } );
					}	
				);		
		break;
		
		case 4 :
			flagaction = false;
			$(".inner-bg").animate({opacity:0}, speed);
			$(".inner-img").animate({opacity:0}, speed);	
			
			$("#cont-section").delay(speedduring).animate({ top :  0}, 'slow',			
				function (){		
					$("#slide" + myslide + " .inner-bg").animate({opacity:1}, speed );
					$("#slide" + myslide + " .inner-img").animate({opacity:1}, speed2, function(){ flagaction = true; } );
					}	
				);		
		break;
		
		case 5 :
			flagaction = false;
			$(".inner-bg").animate({opacity:alphaslide, top : Slideh}, speed);
			$(".inner-img").animate({opacity:alphaslide, top : Slideh}, speed);

			$("#cont-section").delay(speedduring).animate({ top :  0}, 'slow',
				function (){		
					$("#slide" + myslide + " .inner-bg").animate({opacity:1, top : 0}, speed );
					$("#slide" + myslide + " .inner-img").animate({opacity:1, top : 0}, speed2, function(){ flagaction = true; } );
					}	
				);		
		break;
		
		case 6 :
			flagaction = false;
			$(".inner-bg").animate({opacity:alphaslide, top : -Slideh}, speed);
			$(".inner-img").animate({opacity:alphaslide, top : -Slideh}, speed);

			$("#cont-section").delay(speedduring).animate({ top :  0}, 'slow',
				function (){		
					$("#slide" + myslide + " .inner-bg").animate({opacity:1, top : 0}, speed );
					$("#slide" + myslide + " .inner-img").animate({opacity:1, top : 0}, speed2, function(){ flagaction = true; } );
					}	
				);		
		break;	
		
		}
	}

$(window).load(function () {  
  $("#cont-section-global").css("visibility", "visible");
  $("#cont-section-global img").css("visibility", "visible");
  $("#cont-section-global").css("background", "transparent");
  $("#cont-section").css("visibility", "visible");
  open_slide(0);
  var dc_time = setInterval(autoslide, autodelay); 	
  
  
	// Events
	window.onblur = function(){flag=false;time_cpt = -1000000000000;}  
	window.onfocus = function(){flag=true;time_cpt=1;}  
  
});

function autoslide(){

	if(flag){	
		if(current > ($('#cont-section-global .inner-img img').length-1)){current=0;}
		$("#pagination a").removeClass('selected');
		$("#pagination #btn-parallax-" + current).addClass('selected');
		open_slide(current);
		current++;		
		}
	else{		
		if(time_cpt < 2){time_cpt++;}
		else{flag=true;time_cpt=1;current++;}
		}	
	}	
	
	
}


