function init_diapo(init_nb_current) {

	jQuery(function() {

		//VAR D'INIT
		var init_id_div="f_slider_img"; //id de la div slider
		var id_item="fsi_img_";
		var class_item="fsi_img";
		var id_bt_next="slide_next";
		var id_bt_prev="slide_prev";
		var duree_anim = 800; //duree de la transition
		var delay = 4500; //duree entre 2 autoplay
		var global_auto_play = 1; //si y'a possibilité d'autoplay ou pas
		var auto_play = 1; //l'autoplay au démarrage

		var div_global = null;
		var div_current = null;

		var nb_slide = 0;
		var nb_current = init_nb_current;

		var anim=0; //si animation en cours ou no
		var anim2='-1'; //id de celui qu'il faudra afficher
		var anim2_sens=0; //0=next | 1=prev
		var on_slider=0; //si le curseur est au dessus du slider
		var move_btn=0; //si les boutons de slide/bande d'information sont en mouvement
		var bt_affiche=0; //si les boutons/bande d'info est affichée ou pas
		var breaking=0;
		var global_bloc = 0; //si y'a qu'une image || 0

		//on vérifie que la div globale existe (si y'a oui ou non des imgs dans le slider)
		if ( !(get_id(init_id_div)) ) {
			global_bloc = 1;
		}
		else {

			div_global = jQuery("#" + init_id_div);

			//recup le nombre d'éléments
			nb_slide = div_global.find("." + class_item).length;

			if (nb_slide < 2) {
				global_bloc = 1;
			}

			//lancement du défilement auto si y'en a un
			if (auto_play == 1) {
				play();
			}

			//initialistion
			div_current = jQuery("#" + id_item + nb_current);

			//on les cache tous, sauf le current
			div_global.find("." + class_item).hide();
			div_current.show();

			//bouton next / prev
			jQuery("#" + id_bt_next).click( function() {
				next(0);
			});

			jQuery("#" + id_bt_prev).click( function() {
				prev();
			});

			//grosse image click => next
			jQuery("." + class_item).click( function() {
				next(0);
			});

			/*miniature
			jQuery(".photo_min").click( function() {
				slideto_min( this.id );
			});
			*/

			//quand on est dans le slider
			div_global.mousemove( function() {
				on_slider=1;
				auto_play=0;
				show_bouton();
			} );

			//quand on sort du slider
			div_global.mouseleave( function() {
				if (global_auto_play == 1) {
					if (breaking == 0) {
						auto_play=1;
					}
					on_slider=0;

					play();
				}

				hide_bouton();

			} );

		}

		//fonction de transition entre la div_current, et l'id appelé (ou la "next")
		function slideto(nb_next) {

			if ((nb_next != nb_current) && (anim==0) && (global_bloc != 1) ) {

				anim=1;

				jQuery("#" + id_item + nb_next).animate({
						top:"0px",
						height:"0px"
					}, 0, function() {

							jQuery("#" + id_item + nb_current).animate({
									top:"250px",
									height:"0px"
								}, duree_anim, "easeInOutQuart"
							);

							jQuery("#" + id_item + nb_next).show();

							jQuery("#" + id_item + nb_next).animate({
									top:"0px",
									height:"250px"
								}, duree_anim, "easeInOutQuart", function() {

										jQuery("#" + id_item + nb_current).hide();

										anim = 0;

										nb_current = nb_next;

										if (anim2 != '-1') {

											if (anim2_sens == 0) {
												slideto(anim2);
											}
											else {
												slideto_prev(anim2);
											}

											setTimeout( function() { anim2='-1'; }, 200 );

										}

										//si on a un défil auto, on en relance un
										if (global_auto_play == 1) {
											//on empeche des autoslide de se faire sans pause
											break_slide();
											setTimeout( function() { next(1); }, delay );
										}

									}
							);


						}

				);


				/*

					GESTION D'UN TITRE D'IMAGE

				jQuery("#titre_photo").hide("fade", parseInt(duree_anim / 2), function() {

					get_id("titre_photo").innerHTML = get_value("titre_" + nb_next);

					jQuery("#titre_photo").show("fade", parseInt(duree_anim / 2));

				});
				*/

			}

		}
		//fin slideto




		//fonction de transition entre la div_current, et l'id appelé (ou la "next")
		function slideto_prev(nb_next) {

			if ((nb_next != nb_current) && (anim==0) && (global_bloc != 1) ) {

				anim=1;

				jQuery("#" + id_item + nb_next).animate({
						top:"250px",
						height:"0px"
					}, 0, function() {

							jQuery("#" + id_item + nb_current).animate({
									top:"0px",
									height:"0px"
								}, duree_anim, "easeInOutQuart"
							);

							jQuery("#" + id_item + nb_next).show();

							jQuery("#" + id_item + nb_next).animate({
									top:"0px",
									height:"250px"
								}, duree_anim, "easeInOutQuart", function() {

										jQuery("#" + id_item + nb_current).hide();

										anim = 0;

										nb_current = nb_next;

										if (anim2 != '-1') {

											if (anim2_sens == 0) {
												slideto(anim2);
											}
											else {
												slideto_prev(anim2);
											}

											setTimeout( function() { anim2='-1'; }, 200 );

										}

										//si on a un défil auto, on en relance un
										if (global_auto_play == 1) {
											//on empeche des autoslide de se faire sans pause
											break_slide();
											setTimeout( function() { next(1); }, delay );
										}

									}
							);


						}

				);


				/*

					GESTION D'UN TITRE D'IMAGE

				jQuery("#titre_photo").hide("fade", parseInt(duree_anim / 2), function() {

					get_id("titre_photo").innerHTML = get_value("titre_" + nb_next);

					jQuery("#titre_photo").show("fade", parseInt(duree_anim / 2));

				});
				*/

			}

		}
		//fin slideto_prev




		/*
		function slideto_min(id) {
			slideto(id.substr(4,10));
		}
		*/


		//si c'est un next auto, si on est sur le slider ou en pause, on annule
		function next(auto) {

			if (auto == 1) {
				if ((on_slider == 1) || (breaking==1)) { return false; }
			}

			//si une anim est en cours ET qu'on a pas une anim déjà de prévue (on prévoit la future anim)
			if ( (anim == 1) && (anim2 == '-1') ) {

				if ( parseInt(nb_current+1) >= nb_slide) {
					anim2 = 1;
				}
				else {
					anim2 = parseInt( parseInt(nb_current)+1+1);
				}

				anim2_sens=0;

			}
			//SINON SI ON EST PAS DEJA EN TRAIN DE FAIRE UNE ANIM => ON FAIT ANIM
			else if (anim != 1) {

				if ( parseInt(nb_current) == nb_slide) {
					slideto(1);
				}
				else {
					slideto( parseInt( parseInt(nb_current)+1) );
				}

			}
			//SINON RIEN

		}

		//si c'est un next auto, si on est sur le slider ou en pause, on annule
		function prev() {

			//si une anim est en cours ET qu'on a pas une anim déjà de prévue (on prévoit la future anim)
			if ( (anim == 1) && (anim2 == '-1') ) {

				if ( parseInt(nb_current-1) <= 1) {
					anim2 = nb_slide;
				}
				else {
					anim2 = parseInt( parseInt(nb_current)-1-1);
				}

				anim2_sens=1;

			}
			//SINON SI ON EST PAS DEJA EN TRAIN DE FAIRE UNE ANIM => ON FAIT ANIM
			else if (anim != 1) {

				if (nb_current == 1) {
					slideto_prev(nb_slide);
				}
				else {
					slideto_prev( parseInt( parseInt(nb_current)-1) );
				}

			}
			//SINON RIEN


		}

		function show_bouton() {
			jQuery("#" + id_bt_prev).show();
			jQuery("#" + id_bt_next).show();
			bt_affiche=1;
		}

		function hide_bouton() {
			jQuery("#" + id_bt_prev).hide();
			jQuery("#" + id_bt_next).hide();
			bt_affiche=0;
		}


		//lance un défilement automatique
		function play() {

			if (global_auto_play == 1) {

				setTimeout( function() {

							if ((auto_play == 1) && (anim==0) && (on_slider==0) && (breaking==0)) {
								next(1);
							}

						}, delay )
			}

		}


		//fait une pause pour éviter des bugs
		function break_slide() {

			if (global_auto_play == 1) {
				if (breaking == 0) {
					breaking=1;
					auto_play=0;
					setTimeout( function() { auto_play=1;breaking=0; }, (delay - 5) );
				}
			}
		}


	});

}

init_diapo(1);
