var tempo = 25;
var prefixe_div;
var buffer;
var top;
var s1;
var s2;
var bottom;
var pos_min;
var pos_max;
//var index_max;
var initDone = false;
var is_over_link = false;

/*
* initialisation des variables pour le défilement
*/
function initDefileur(prefixe,h_min,h_max){
	prefixe_div = prefixe
	buffer = 1;
	top = 2;
	s1 = 3;
	s2 = 4;
	bottom = 5;
	initDone = true;
	pos_min = h_min;
	pos_max = h_max
}

function vers_le_haut(){
	if(initDone){
		//recuperation des elt html
	    div_buffer=document.getElementById(prefixe_div+ buffer );
	    div_top=document.getElementById(prefixe_div+ top );
	    div_s1=document.getElementById(prefixe_div+ s1 );
	    div_s2=document.getElementById(prefixe_div+ s2 );
	    div_bottom=document.getElementById(prefixe_div+ bottom );
	
		// recuperation de la position des elt html
	    if (div_top!=null){pos_top=parseInt(div_top.style.top);}
	    if (div_s1!=null){pos_s1=parseInt(div_s1.style.top);}
	    if (div_s2!=null){pos_s2=parseInt(div_s2.style.top);}
	    if (div_bottom!=null){pos_bottom=parseInt(div_bottom.style.top);}
	    
		// affectation de la nouvelle position aux elt html
        div_top.style.top=pos_top - pas +"px";
        div_s1.style.top=pos_s1 - pas +"px";
        div_s2.style.top=pos_s2 - pas +"px";
        div_bottom.style.top=pos_bottom - pas +"px";

	    if(pos_top <= pos_min){
			//reaffectation des blocs si celui du haut n'est plus visible
			tmp = top;
			top = s1;
			s1 = s2;
			s2 = bottom;
			bottom = buffer;
			buffer = tmp;
			
			//on replace bottom
		    div_bottom=document.getElementById(prefixe_div+ bottom );
	        div_bottom.style.top= pos_max +"px";

	        makeContent(div_buffer,getNextId());
		}

		setTimeout(methode,tempo);
	}
}

function vers_le_bas(){
	if(initDone){
		//recuperation des elt html
	    div_buffer=document.getElementById(prefixe_div+ buffer );
	    div_top=document.getElementById(prefixe_div+ top );
	    div_s1=document.getElementById(prefixe_div+ s1 );
	    div_s2=document.getElementById(prefixe_div+ s2 );
	    div_bottom=document.getElementById(prefixe_div+ bottom );
	
		// recuperation de la position des elt html
	    if (div_top!=null){pos_top=parseInt(div_top.style.top);}
	    if (div_s1!=null){pos_s1=parseInt(div_s1.style.top);}
	    if (div_s2!=null){pos_s2=parseInt(div_s2.style.top);}
	    if (div_bottom!=null){pos_bottom=parseInt(div_bottom.style.top);}
	    
		// affectation de la nouvelle position aux elt html
        div_top.style.top=pos_top + pas +"px";
        div_s1.style.top=pos_s1 + pas +"px";
        div_s2.style.top=pos_s2 + pas +"px";
        div_bottom.style.top=pos_bottom + pas +"px";

	    if(pos_bottom >= pos_max){
			//reaffectation des blocs si celui du haut n'est plus visible
			tmp = bottom;
			bottom = s2;
			s2 = s1;
			s1 = top;
			top = buffer;
			buffer = tmp;
			
			//on replace top
		    div_top=document.getElementById(prefixe_div+ top );
	        div_top.style.top= pos_min +"px";

	        makeContent(div_buffer,getPreviousId());
		}

		setTimeout(methode,tempo);
	}
}

